Skip to content

Commit

Permalink
fix: use custom fetcher inside page download
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Jan 17, 2024
1 parent 3241d68 commit cbb7674
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/login/informations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const callApiLoginInformations = makeApiHandler<ApiLoginInformations>(asy
const accountType = PRONOTE_ACCOUNT_TYPES.find((entry) => entry.id === input.accountTypeID);
if (!accountType) throw new Error(`Invalid account type ID: ${input.accountTypeID}`);

const pronotePage = await downloadPronotePage({
const pronotePage = await downloadPronotePage(fetcher, {
pronoteURL: input.pronoteURL,
// Those cookies are very important since they're like the *initializer*.
//
Expand Down
5 changes: 3 additions & 2 deletions src/pronote/page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { PawnoteFetcher } from "~/utils/fetcher";
import { MOBILE_CHROME_USER_AGENT } from "~/constants/user-agent";
import { retrieveResponseCookies } from "~/utils/headers";

export const downloadPronotePage = async (options: {
export const downloadPronotePage = async (fetcher: PawnoteFetcher, options: {
pronoteURL: string
cookies?: string[]
}): Promise<{
Expand All @@ -11,7 +12,7 @@ export const downloadPronotePage = async (options: {
cookies: string[]
}> => {
try {
const response = await fetch(options.pronoteURL, {
const response = await fetcher(options.pronoteURL, {
method: "GET",
redirect: "manual",
headers: {
Expand Down

0 comments on commit cbb7674

Please sign in to comment.