Skip to content

Instantly share code, notes, and snippets.

@gNaps
Created August 25, 2023 10:12
Show Gist options
  • Select an option

  • Save gNaps/1c36de9971ac4e82ec5d8c855c3b42af to your computer and use it in GitHub Desktop.

Select an option

Save gNaps/1c36de9971ac4e82ec5d8c855c3b42af to your computer and use it in GitHub Desktop.
twitch example api - get follows
export const getFollows = async (
userId: number,
accessToken: string,
after: string = "",
follows: any = []
): Promise<any> => {
const response = await fetch(
`${TWITCH_URL_API}/users/follows?from_id=${userId}${
after ? `&after=${after}` : ""
}`,
{
headers: {
"Client-Id": process.env.NEXT_PUBLIC_CLIENT_ID,
Authorization: "Bearer " + accessToken,
},
}
);
const data = await response.json();
follows = [...follows, ...data.data];
if (data.pagination && data.pagination.cursor) {
return await getFollows(
userId,
accessToken,
data.pagination.cursor,
follows
);
}
return follows;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment