let headers = {
"Content-Type": "application/json",
"Authorization": "token=" + this.props.login.token,
"Accept-Language": this.props.language.language,
};
-
1login prop is undefined. How do you pass the login prop to the component? Please give more details.Tabish Javed– Tabish Javed2020-01-14 05:58:21 +00:00Commented Jan 14, 2020 at 5:58
Add a comment
|
2 Answers
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)
});