UNPKG

@cisco-meraki/dashboard-api-tools

Version:

Typescript library for interacting with Meraki's public API

60 lines (59 loc) 2.4 kB
import { FetchArgs, fetchBaseQuery as originalFetchBaseQuery } from "@reduxjs/toolkit/query/react"; declare type FetchWrapper = ReturnType<typeof originalFetchBaseQuery>; declare type FetchWrapperOpts = Parameters<FetchWrapper>; declare type FetchWrapperApiOpts = FetchWrapperOpts[1]; declare type QueryParam = string | number; /** * fetchBaseQuery returns a fetch-like wrapper that is used internally by Redux. * * **NOTE:** This version of fetchBaseQuery does not support responseHandler or * validateStatus. The reason is because apiRequest already performs this * functionality. See: * https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery#parsing-a-Response * and * https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery#handling-non-standard-response-status-codes */ export declare function fetchBaseQuery(baseOpts: { baseUrl: `${string}/`; /** * Needed in order to transform query params into a search URL. * In manage, use `lib/url/buildQueryParams`. */ paramsSerializer: (params: Record<string, QueryParam | QueryParam[] | undefined>) => string; /** * Optionally transform headers based on things like the current redux state. */ transformHeaders?: (rawHeaders: Headers, api: Pick<FetchWrapperApiOpts, "getState" | "extra" | "endpoint" | "type" | "forced">) => Promise<Headers>; /** * Optionally pause all requests until the promise returned by this method * resolves. In theory, you can pause requests based on the headers and * current redux state, for example. */ pauseUntilResolved?: (headers: HeadersInit, api: Pick<FetchWrapperApiOpts, "getState" | "extra" | "endpoint" | "type" | "forced">) => Promise<void>; }): (args: string | FetchArgs, api: import("@reduxjs/toolkit/dist/query/baseQueryTypes").BaseQueryApi, extraOptions: {}) => Promise<{ data: unknown; meta: { firstPageUrl: string | null; lastPageUrl: string | null; nextPageUrl: string | null; prevPageUrl: string | null; linkHeader: string | null; retryAfter: number | null; errors: null; ok: true; statusCode: number; statusText: string; }; error?: never; } | { error: { errors: string[]; }; data?: never; meta?: never; } | { error: import("..").ApiError; data?: never; meta?: never; }>; export {};