aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data/AniList/follow.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-09 00:41:20 -0700
committerFuwn <[email protected]>2024-10-09 00:41:43 -0700
commit998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch)
tree50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Data/AniList/follow.ts
parentfeat(graphql): add badgeCount field (diff)
downloaddue.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz
due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Data/AniList/follow.ts')
-rw-r--r--src/lib/Data/AniList/follow.ts80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/lib/Data/AniList/follow.ts b/src/lib/Data/AniList/follow.ts
index f03193cb..d450c57f 100644
--- a/src/lib/Data/AniList/follow.ts
+++ b/src/lib/Data/AniList/follow.ts
@@ -1,49 +1,49 @@
import type { AniListAuthorisation } from './identity';
export interface User {
- id: number;
- name: string;
- isFollowing: boolean;
- isFollower: boolean;
- avatar: {
- large: string;
- medium: string;
- };
+ id: number;
+ name: string;
+ isFollowing: boolean;
+ isFollower: boolean;
+ avatar: {
+ large: string;
+ medium: string;
+ };
}
export const toggleFollow = async (
- anilistAuthorisation: AniListAuthorisation,
- username: string
+ anilistAuthorisation: AniListAuthorisation,
+ username: string
): Promise<User> => {
- const {
- data: { User: user }
- } = await (
- await fetch('https://graphql.anilist.co', {
- method: 'POST',
- headers: {
- Authorization: `${anilistAuthorisation.tokenType} ${anilistAuthorisation.accessToken}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json'
- },
- body: JSON.stringify({
- query: `{ User(name: "${username}") { id } }`
- })
- })
- ).json();
+ const {
+ data: { User: user }
+ } = await (
+ await fetch('https://graphql.anilist.co', {
+ method: 'POST',
+ headers: {
+ Authorization: `${anilistAuthorisation.tokenType} ${anilistAuthorisation.accessToken}`,
+ 'Content-Type': 'application/json',
+ Accept: 'application/json'
+ },
+ body: JSON.stringify({
+ query: `{ User(name: "${username}") { id } }`
+ })
+ })
+ ).json();
- return (
- await (
- await fetch('https://graphql.anilist.co', {
- method: 'POST',
- headers: {
- Authorization: `${anilistAuthorisation.tokenType} ${anilistAuthorisation.accessToken}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json'
- },
- body: JSON.stringify({
- mutation: `{ ToggleFollow(userId: ${user.id}) { id name isFollowing isFollower } }`
- })
- })
- ).json()
- )['data']['ToggleFollow'];
+ return (
+ await (
+ await fetch('https://graphql.anilist.co', {
+ method: 'POST',
+ headers: {
+ Authorization: `${anilistAuthorisation.tokenType} ${anilistAuthorisation.accessToken}`,
+ 'Content-Type': 'application/json',
+ Accept: 'application/json'
+ },
+ body: JSON.stringify({
+ mutation: `{ ToggleFollow(userId: ${user.id}) { id name isFollowing isFollower } }`
+ })
+ })
+ ).json()
+ )['data']['ToggleFollow'];
};