tsuite
    Preparing search index...

    Function createRequest

    • Creates a new Request instance for making fetch requests.

      Parameters

      • input: FetchInput

        The input for the fetch request. This can be a URL string or a RequestInfo object.

      • Optionalinit: FetchInit

        An optional object containing custom settings for the fetch request. This can include properties like method, headers, body, etc. It can also include an event property with a fetch function for custom fetch implementations (e.g., for testing).

      Returns Request

      A Request instance. Note: You should not call this function without chaining either the .getJson() or .getText() method to retrieve the response data.

      use effetch instead

      // Correct usage:
      createRequest('https://api.example.com/data').getJson()
      .then((data) => console.log(data))
      .catch((error) => console.error(error));

      // Incorrect usage (will not make the request):
      const myRequest = createRequest('https://api.example.com/data'); // This won't trigger the fetch