1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { fetch } from "https://esm.town/v/std/fetch";
import { API_BASE_URL } from "https://esm.town/v/mangadex/API_BASE_URL";
type LoginSuccess = {
result: "ok";
token: {
session: string;
refresh: string;
};
};
type LoginFailure = {
result: "error";
errors: Array<{
id: string;
status: number;
title: string;
detail: string;
}>;
};
type LoginResponse = LoginSuccess | LoginFailure;
/**
* Returns all chapters for a given Mangadex list.
*/
export const listFeed = async (listId: string, login: LoginResponse) => {
if (login.result === "error") {
return "The provided login credentials are incorrect.";
}
const response = await fetch(
`${API_BASE_URL}/list/${listId}/feed`,
{
headers: {
Authorization: `Bearer ${login.token.session}`,
},
},
);
return await response.json();
};