axios bearer token
{
headers: {
'Authorization': 'Bearer ' + validToken()
}
}
axios bearer token
{
headers: {
'Authorization': 'Bearer ' + validToken()
}
}
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)
});
header in axios
axios.post('url', {"body":data}, {
headers: {
'Content-Type': 'application/json'
}
}
)
axios.interceptors.response.use
// Add a response interceptor
HTTP.interceptors.response.use(function (response) {
return response
}, function(error) {
if (error.response.status === 401) {
store.dispatch('logout')
router.push('/login')
}
return Promise.reject(error.response.data)
})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us