Skip to content

Instantly share code, notes, and snippets.

@fmoliveira
Created April 9, 2022 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmoliveira/3fba88db63fbaaf6eb7e962e466dabcf to your computer and use it in GitHub Desktop.
Save fmoliveira/3fba88db63fbaaf6eb7e962e466dabcf to your computer and use it in GitHub Desktop.
Unfollow all on spotify
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