We make the option to be a shared options object. This allow our other function do not depend on the context, but the shared variable, so we can separate api into files.

interface Options {
    acceptLanguage?: string;
    baseURL?: string;
    cookie?: string;
    fetch?: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    };
    xUserId?: string
    | number;
}

Properties

acceptLanguage?: string

This will affect pixiv translation related fields, no need if run in browser

"zh-CN"
baseURL?: string
"https://www.pixiv.net"
cookie?: string

The cookie header

fetch?: {
    (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
    (input: string | URL | Request, init?: RequestInit): Promise<Response>;
}

Type declaration

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

    • (input: string | URL | Request, init?: RequestInit): Promise<Response>
    • Parameters

      • input: string | URL | Request
      • Optionalinit: RequestInit

      Returns Promise<Response>

xUserId?: string | number