Answer the question
In order to leave comments, you need to log in
Why does axios.interceptor send the current data, as well as all past data, when intercepting a request?
Hello.
There is an interceptor that consoles the current token from the storage every time a request is made to any address:
useMemo(()=>{
axios.interceptors.request.use( config=>{
console.log(props.jwtAccessToken)
return config
},(err)=>{
return Promise.reject(err)
})
},[props.jwtAccessToken])
const logIn = () => {
if (!user.email || !user.password) {
console.log('Enter login and password')
return
}
const userData = JSON.stringify(user)
axios.request({ url: '/api/logInUser', method: 'post', data: userData, headers: { 'Content-Type': 'application/json' } })
.then(response => {
if (response.data.jwtAccessToken) {
props.setJWT(response.data.jwtAccessToken)
}
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question