Axios request response 401 in React app, but working in Postman?

Viewed 944

Might be missing something obvious here, but I am able to use an access token to skip songs and queue items, on behalf of a user, from postman with response 204 (success). In my application, however, I can retrieve playlists just fine, but queueing and skipping songs results in status code 401.

Also, requests such as retrieving playlists and their content works just fine.

I read some stuff about having the right scopes and possible expiration of tokens on the internet regarding 401, however, why would it then succeed from Postman?

How can this be the case? Ì don't immediately see any syntax mistakes.

Pictures for context:

enter image description here

enter image description here

1 Answers

The issue is that you're passing in the header configuration to axios.post() as the wrong argument; axios is interpreting your attempt to set the headers as the POST body, instead of the request configuration. Try axios.post(/* Spotify URL */, {}, /* header config */).

Related