1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

Request

The Request interface represents an HTTP request and integrates the Fetch API.

How it works

The Request object can be built and also seen as the property of a fetchevent received by edge function.

  addEventListener("fetch", event => {
    const request = event.request
    const url = "https://example.com"
  
    const myRequest = new Request(url, {
      body: request.body,
      headers: request.headers,
      method: request.method,
      redirect: request.redirect
    })
  })
  addEventListener("fetch", event => {
  let request = event.request
  })

Constructor

  let request = new Request(input [, init])

Parameters

Input: string | Request - defines the resource you want to search for by using a URL or Request object.

Init: RequestInit - optional

Properties

All properties of an initial Request object in event.request are defined as read-only. To modify a request, you must create a new Request object and pass the options to the builder, described as follows.

headers - contains an Headers object.

method - contains the request method - GET, POST, for example.

url - contains the URL request.

body - a simple” getter “to read the body’s contents through the ReadableStream interface.

bodyUsed - stores a Boolean that declares whether the request body has already been used in a response.

redirect - contains the redirection mode to use: follow, error, or manual.

event.type: string

event.request: request

For more information on Request visit MDN Web Docs.


Didn’t find what you were looking for? Open a support ticket.