spotify api error parsing json

Solutions on MaxInterview for spotify api error parsing json by the best coders in the world

showing results for - "spotify api error parsing json"
Paolo
20 Aug 2019
1//mandatory to parse to JSON before posting the request
2
3const getPlaylistId = async (playlistName) => {
4  const userId = await getUserId();
5  const body = JSON.stringify({
6    name: playlistName,
7  });
8
9  const responseCreatedPlaylist = await fetch(
10    `https://cors-anywhere.herokuapp.com/${baseUrl}/users/${userId}/playlists`,
11    {
12      method: "POST",
13      headers: { 
14        "Authorization": `Bearer ${accessToken}`, 
15		"Content-Type": 
16		"application/json" 
17		},
18      body,
19    }
20  );
21  const { id } = await responseCreatedPlaylist.json();
22
23  return id;
24};
25