I am trying to make a request in axios. The same request works in postman.
await axios({
method: "post",
url: `https://ecommersappbytim.herokuapp.com/info/${userId}/update-user`,
header: {
"Content-Type": "application/json",
"auth-token": { token },
},
data: {
firstName: userInfo.fName,
lastName: userInfo.lName,
email: userInfo.email,
password: userInfo.password,
},
})
Is there something I am missing? I have made sure that I am passing in the correct data.
I have found the same error, apparently it is a CORS problem with the headers. What worked for me was passing the token through the url in the form of a query and receiving it in the backend through passport with its jwtFromRequest: ExtractJWT.fromUrlQueryParameter('auth-token').
I don't know if it is the most optimal way to pass the token to the backend but it is the one that worked for me.
I hope this has helped you.