0
I am trying to make a request with Axios for a server, and for that I need to send an access token. The token is correct, but nothing is loading on the network and the request is not working
componentDidMount() {
const token = AsyncStorage.getItem('token').then((value) => {
console.log(value);
});
const headers = {
'Authorization': 'Bearer' + token
}
axios.get("http://192.168.0.117/api/produtos", {
headers: headers
}).then(function (response) {
console.log(response.data);
}).catch(error => {
console.log(error)
})
}
Luan, on the console you put there after you pick up the token value, is it displaying correctly? Another detail is there in the Bearer where the quotes are together 'Bearer'+ token will return you something like Bearer12345 if the token was 12345. Watch this and tell me here if gave.
– Carlos Querioz
Good morning, you are displaying the token correctly yes. but the Bearer + token ta appearing {Authorization: "Bearerundefined"}
– Luan
Vlw by touch only so I could solve.
– Luan