Created
August 25, 2023 10:12
-
-
Save gNaps/1c36de9971ac4e82ec5d8c855c3b42af to your computer and use it in GitHub Desktop.
twitch example api - get follows
This file contains hidden or 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
| 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