Typescript Error Property 'name' does not exist on type 'Object'

Asked

Viewed 3,133 times

0

I am trying to make an appointment in the backend and with the result save in a localstorage. I am using Angular5.

valor:any;

validar(){
 this.storage.get('refresh').then(val => {
  this.loginProvider.refresh(val).subscribe(
   res => {
    this.valor=res.nome;
    this.storage.set('token', this.valor);
   },
   error => {  }
  );
 });
}

when testing gives error: Typescript Error Property 'name' does not exist on type 'Object'.

Can someone help me with this? Thanks

1 answer

1

Try it this way:

valor:any;

validar(){
 this.storage.get('refresh').then(val => {
  this.loginProvider.refresh(val).subscribe(
   (res:any)=> {
    this.valor=res.nome;
    this.storage.set('token', this.valor);
   },
   error => {  }
  );
 });
}

or make a map with any that tbm works

.pipe(map(res=> res as any))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.