Fetch

The Fetch Web API allows you to asynchronously make HTTP requests from your Repeat.

Signature

fetch(
	request: Request | string,
	requestInitr?: RequestInit | Request
): Promise<Response>;

Parameters

  • request: Request
    • A Request object that represents the incoming request to your Repeat web hooks, or a newly constructed request that you can then pass to the fetch method. For simple requests, you can simply pass a URL & your Repeat will make a GET request.

  • requestInitR The requestInitr object contains options for the outgoing request - such as the HTTP request method or a map of headers.
    • Example Usage
      How to use options in a Request constructor
      const request = new Request("https://httpbin.org/anything", {
      	method: "POST",
      	body: "123",
      	headers: {
      		"X-FOO": "BAR"
      	}
      });

Returns

  • response: Response
    • A Response object that represents the response for your request.

      Example Usage
      const response = await fetch("https://google.com");
      
      console.log(`response status: ${response.status}`);

Examples

Fetch a webpage that returns JSON content

Example #1
const response = await fetch("https://httpbin.org/uuid");

const json = await response.json();

console.log(json.uuid);
// 98e4421e-58ab-4740-b9bb-e5446d43a164

 
 

Last updated on November 20, 2022