I am using Django Rest Framework for authentication and Axios in the frontend. When I pass the token to an axios.get method directly it fetches the API endpoint (getUserInfo) correctly, but when I use a variable (string) and pass it dynamically it fails and it gives the error described above.
First case: (succeeds)
const config = {
headers: { Authorization: 'Bearer <token string>' },
};
await axios.get(URLS.FETCH_USER, config)
Second case: (fails)
const config = {
headers: { Authorization: `Bearer ${accessToken}` },
};
await axios.get(URLS.FETCH_USER, config).etc
Note that the token is fresh and taken directly from a postman login request.