Answer the question
In order to leave comments, you need to log in
Is it possible to change the axios config without reloading the script?
I hang the token in the headers of all requests, if there is one in the local store.
const user = JSON.parse(window.localStorage.getItem('user')) || false
if (user)
{
if (user.token)
{
config.headers = {
'token': JSON.stringify(user.token)
}
}
}
Answer the question
In order to leave comments, you need to log in
it's your focus on the top slider that works.
add in fancybox options backFocus: false
Error in JS.
And then when you click on the "link" it draws # to the url, and thus throws it to the top.
it is not clear: at what point it is required to change the token, and to what.
Of course, you can reconfigure axios at any time. It takes the settings in this order :
You did not provide the code where you substitute token in the axios parameters. Let's say something global:
Similarly, later, when you need to change the token, do something like this:
axios.defaults.headers.common['Authorization'] = NEW_TOKEN;
axios.get('https://google.com').then(r => console.log(r));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question