tsuite
    Preparing search index...

    Function effetch

    Effective fetch

    Sends the request and returns the response as parsed JSON (or text).

    The expected type of the JSON response

    A promise that resolves to the parsed JSON or text data

    If the fetch request fails or if the JSON parsing fails

    • Type Parameters

      • T

      Parameters

      • input: RequestInfo | URL
      • Optionalinit: RequestInit & {
            event?: {
                fetch: {
                    (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                    (input: string | Request | URL, init?: RequestInit): Promise<Response>;
                };
            };
            responseType?: "text"
            | "json";
        } & { responseType?: "json" }
        • Optionalevent?: {
              fetch: {
                  (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                  (input: string | Request | URL, init?: RequestInit): Promise<Response>;
              };
          }

          Primarily for SvelteKit's load function

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

      Returns Promise<T>

    • Parameters

      • input: RequestInfo | URL
      • init: RequestInit & {
            event?: {
                fetch: {
                    (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                    (input: string | Request | URL, init?: RequestInit): Promise<Response>;
                };
            };
            responseType?: "text"
            | "json";
        } & { responseType: "text" }
        • Optionalevent?: {
              fetch: {
                  (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                  (input: string | Request | URL, init?: RequestInit): Promise<Response>;
              };
          }

          Primarily for SvelteKit's load function

          • fetch: {
                (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                (input: string | Request | URL, init?: RequestInit): Promise<Response>;
            }
        • OptionalresponseType?: "text" | "json"
        • responseType: "text"

      Returns Promise<string>