JavaScripture
Contribute via GitHub Feedback

Request : Object

Request is used to describe an request to a server. Use with fetch() to perform the request and get a Response. Request, fetch(), and Response are a new, low level replacement for XMLHttpRequest.

Constructors

new Request(url : String, [init : Object]) : Request
init : {
body :ObjectThe data to send with the request. Must be a Blob, BufferSource, FormData, String, or URLSearchParams.
cache :StringSee the cache property for the valid values.
credentials :StringSee the credentials property for the valid values.
headers :ObjectThe http headers to send with the request. This will be passed to the Headers constructor.
integrity :String
keepalive :Boolean
method :StringThe http method such as 'GET', 'POST', 'DELETE'.
mode :StringSee the mode property for the valid values.
redirect :StringOne of 'follow', 'error', or 'manual'
referrer :String
referrerPolicy :StringOne of '', 'no-referrer', 'no-referrer-when-downgrade', 'same-origin', 'origin', 'strict-origin', 'origin-when-cross-origin', 'strict-origin-when-cross-origin', or 'unsafe-url'
requestMode :StringOne of 'navigate', 'same-origin', 'no-cors', or 'cors'
requestCredentials :StringOne of 'omit', 'same-origin', or 'include'
signal :AbortSignal
}

Example:

Run

Results:

 

new Request(request : Request, [init : Object]) : Request

Instance Properties

bodyUsed : Boolean  

cache : String  

Will be one of: 'default', 'force-cache', 'no-cache', 'no-store', 'only-if-cached', 'reload'.

credentials : String  

Will be one of: 'include', 'omit', 'same-origin'.

destination : String  

Will be one of: '', 'audio', 'audioworklet', 'document', 'embed', 'font', 'frame', 'iframe', 'image', 'manifest', 'object', 'paintworklet', 'report', 'script', 'sharedworker', 'style', 'track', 'video', 'worker', 'xslt'.

headers : Headers  

integrity : String  

isHistoryNavigation : Boolean  

isReloadNavigation : Boolean  

keepalive : Boolean  

method : String  

mode : String  

Will be one of: 'same-origin', 'no-cors', 'cors'.

redirect : String  

referrer : String  

referrerPolicy : String  

signal : AbortSignal  

url : String  

Instance Methods

arrayBuffer() : Promise<ArrayBuffer>

Returns a Promise to the body of the request as an ArrayBuffer.

Example:

Run

Results:

 

blob() : Promise<Blob>

Returns a Promise to the body of the request as a Blob.

Example:

Run

Results:

 

clone() : Request

formData() : Promise<FormData>

Returns a Promise to the body of the request as a FormData.

json() : Promise<Object>

Parses the body of the request and returns a Promise with the result.

Example:

Run

Results:

 

text() : Promise<String>

Returns a Promise to the body of the request.

Example:

Run

Results: