score:0

issue solved. actually when calling a component and if you don't provide props along with that, we get this error "cannot read property 'token' of undefined". so just pass the props along with the component like {...this.props} and it works well.

score:1

i think you are passing token in wrong way

instead of writing like this

"authorization": "token=" + this.props.login.token,

define like this

"authorization": "bearer " + this.props.login.token,

sample of axios code

axios.post('api_ulr', {
  headers: {'authorization': "bearer " + this.props.login.token}
  }
).then((response) => {
  console.log(response)
}).catch((error) => {
  console.log(error)
});

Related Query

More Query from same tag