Jammming project solution

Hi!

I’ve just finished with the Jammming project, and everything looks good until I try to save playlist.
I get an error saying it’s unable to fulfil fetch in Spotify.js,
I’ve tried commenting everything extra out keeping to the bare minimum of:

fetch(`https://api.spotify.com/v1/users/${userId}/playlists`,{
                    headers: headers,
                    method: 'POST',
                    body: JSON.stringify({name: name})
                })

but I still get the same error.
Does anyone have their completed code that their willing to share.
I usually like to go through the project solutions and see what differences I have, especially when something isn’t quite right, but I can’t seem to find an official codecademy solution for this one and I’ve tried comparing my code to the video solution and it looks identical…
Thanks in advance

Hi there

My fetch requests look like this:

return fetch('https://api.spotify.com/v1/me', { headers: headers })
			.then(response => response.json())
			.then(jsonResponse => {
				userID = jsonResponse.id;
				return fetch(`https://api.spotify.com/v1/users/${userID}/playlists`, 
					{ 
						method: 'POST',
						headers: headersPOST,                   //changed headers for POST
						body: JSON.stringify({ name: playlistName })
					})
                                        .then(response => response.json())
					.then(jsonResponse => { 
						const playlistID = jsonResponse.id;
						return fetch(`https://api.spotify.com/v1/playlists/${playlistID}/tracks`, 
							{
								method: 'POST',
								headers: headersPOST,              //changed headers for POST
								body: JSON.stringify({ uris: trackURIs })
							});
					});
			}).catch(err => console.log(err));

I noticed in the Spotify API docs that there is an additional required key in the headers for the playlist API requests, and I had to change my headers for the post requests to include a Content-Type key:

const headersPOST = { 
			'Authorization': `Bearer ${accessToken}`,
			'Content-Type': 'application/json' 
		};

Does that help?