bearer token and body in the axios.post format code example
Example 1: axios bearer token
{
headers: {
'Authorization': 'Bearer ' + validToken()
}
}
Example 2: autherization token in axios
const api = 'your api';
const token = JSON.parse(sessionStorage.getItem('data'));
const token = user.data.id; /*take only token and save in token variable*/
axios.get(api , { headers: {"Authorization" : `Bearer ${token}`} })
.then(res => {
console.log(res.data);
.catch((error) => {
console.log(error)
});