I'm trying to access http://localhost:8080/api/v1/postulant, but I cannot set the access token in the headers. I do the same request on Postman and it works so it's a problem in the Axios request, what did I do wrong?
let headers = {
Authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjUsImlhdCI6MTYxOTUyNDE4NywiZXhwIjoxNjIwMTI4OTg3fQ.hSXARB-y7rClswYZ380HV5RW77qjYNt5FzW2NfDd8Vw",
"Content-Type": "application/json",
};
axios.get("http://localhost:8080/api/v1/postulant", { headers });
on the api I have this code to control the token:
function Auth(req, res, next) {
console.log(req.headers);
if (!req.headers["authorization"])
res.status(400).json({ message: "token invalid" });
}
and it gives me that for my console log req.header: command prompt result
with my postman request, I have this result : enter image description here
so I didn't find the authorization that I provided in the Axios request