impit
    Preparing search index...

    Class Impit

    The main class of the impit package

    This class is the primary interface for making HTTP requests. It provides methods to configure the Impit instance and to perform requests.

    import { Impit } from 'impit';

    const impit = new Impit();
    const response = await impit.fetch('https://example.com');
    console.log(await response.text());
    Index

    Constructors

    Methods

    Constructors

    • Creates a new Impit instance with the given options.

      The options parameter allows you to customize the behavior of the Impit instance. If no options are provided, default settings will be used.

      Parameters

      Returns Impit

      import { Impit } from 'impit';

      const impit = new Impit({
      timeout: 5e3, // Set a default timeout of 5000
      headers: {
      'Authorization: 'Bearer <token>',
      },
      browser: 'chrome',
      });

    Methods

    • Fetch a URL with the given options.

      This method performs an HTTP request to the specified URL using the provided options. It returns a promise that resolves to an ImpitResponse object containing the response data.

      This method is designed to be API-compatible with the Fetch API fetch global method.

      Parameters

      Returns Promise<ImpitResponse>

      import { Impit } from 'impit';

      const impit = new Impit();
      const response = await impit.fetch('https://example.com', {
      method: 'GET',
      headers: {
      'Accept': 'application/json'
      },
      timeout: 5e3,
      });