/** * @license * react-fetch-it * * Copyright (c) 2026, Brandon D. Sara (https://bsara.dev/) * Licensed under the ISC license (https://github.com/bsara/react-fetch-it/blob/master/LICENSE) */ import { FetchItMiddleware } from "../index.js"; /** * Sets some reasonably default standard options on all requests (all of which are * ignored if a request's options already have an existing setting for the standard * option). Also does some processing on the options given certain conditions * _(see below for details)_. * * Options that are set: * - `credentials` = `'same-origin'` * - `responseType` = `'json'` * - `headers['Accept']` = `'application/json'` _(if `responseType` is `'json'`)_ * - `headers['Accept']` = `'text/plain'` _(if `responseType` is `'text'`)_ * - `headers['Content-Type']` = `'application/json'` _(if `body` is defined and is * stringifiable — i.e. an object, array, string, number, bigint, or boolean, but not an * `ArrayBuffer`, `Blob`, or `FormData`)_ * * Additional actions performed: * - `body` will automatically be converted to an `Array` if it is a `Set` or a typed * array, or to a plain `Object` if it is a `Map`, before the `Content-Type` check above * is performed. * - `body` will automatically be converted using `JSON.stringify` if * `headers['Content-Type']` equals `'application/json'`, `body` is defined and * is not a string. * * * @example ```ts * // You can set globally if you DO NOT expect the need for this middleware to change at runtime. * // You would typically have this code execute via (or in) your main entry file. * * import { addFetchItMiddleware } from "react-fetch-it"; * import standardOptionsMiddleware from "react-fetch-it/middleware/standard-options"; * * addFetchItMiddleware( * standardOptionsMiddleware, * // other middlewares... * ); * ``` * * * @example ```tsx * // You can use a provider if you expect the need for this middleware to change at runtime. * * import FetchItMiddlewareProvider from 'react-fetch-it/MiddlewareProvider'; * import standardOptionsMiddleware from "react-fetch-it/middleware/standard-options"; * * export function MyComponent({ children, ...props }) { * // ... * * return ( * * {children} * * ); * } * ``` */ declare const standardOptionsMiddleware: FetchItMiddleware; export default standardOptionsMiddleware;