Created
April 9, 2022 22:51
-
-
Save fmoliveira/3fba88db63fbaaf6eb7e962e466dabcf to your computer and use it in GitHub Desktop.
Unfollow all on spotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from "node-fetch"; | |
const headers = { | |
Authorization: "Bearer xyz", | |
}; | |
const toJson = (res) => res.json(); | |
const following = await fetch( | |
"https://api.spotify.com/v1/me/following?type=artist", | |
{ headers } | |
).then(toJson); | |
const artists = following.artists.items.map(({ id, name }) => ({ id, name })); | |
console.log(artists); | |
const ids = artists.map((i) => i.id).join(","); | |
const deleteUrl = `https://api.spotify.com/v1/me/following?type=artist&ids=${ids}`; | |
console.log(deleteUrl); | |
await fetch(deleteUrl, { | |
method: "DELETE", | |
headers, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment