⭐️ bestfetch

getRequestKey

💁‍♀️ Heads up! Most apps never need to use this function.

A function that implements the default algorithm of generating a request key.

import { getRequestKey } from 'bestfetch';

Arguments

  1. options (object): An object that contains information about a request.
    The options are:
    • url: The URL of the request.
    • method: The HTTP method of the request.
    • body: The body option of the request.
    • responseType: The responseType option of the request.

Returns

A string that is the request key.

Example Usage

💁‍♀️ Heads up! You can copy and paste the following code snippet into your browser's developer tools to try it out!
const requestKey = getRequestKey({
  url: '/api/books/2',
  method: 'POST',
  body: '{}',
  responseType: 'json'
});

console.log('The request key is:', requestKey);

Keep in mind that bestfetch automatically generates request keys for you, so it's very unlikely that you will ever need to call this function directly.