Spotify API POST request

I am having issues with a POST request to the Spotify API using implicit grant flow:

I am getting this error message when I am trying a POST request:

  "error": {
    "status": 401,
    "message": "No token provided"

The thing is I am passing in an access token by making a headers variable and assigning it to the headers for the post request like this:

const headers = {
            Authorization: `Bearer ${accessToken}`
return fetch(`${userId}/playlists`, {
                'headers': headers,
                method: 'POST',
                body: JSON.stringify({'name': name})

This fetch request is the one giving me the error I stated above. How can I fix this?

Here is the headers object right before the fetch:

Here is the link to the GitHub:

This code is in the src/utils/Spotify document


It seems that getAccessToken on the initial token request doesn’t return (i.e. implicitly returns undefined) and you should get the error already on first fetch (where you’re fetching userId).