fetch

Syntax

fetch(resource);
fetch(resource, options);

Parameters

resource

This defines the resource that you wish to fetch. This can either be:

  • A string or any other object with stringify API — including a URL object — that provides the URL of the resource you want to fetch.

  • A Request object.

options

A RequestInit object containing any custom settings that you want to apply to the request.

Example

const request = new Request('https://jsonplaceholder.typicode.com/todos/1');
const response = await fetch(request);
console.log(await response.json());

Compatibility

INFO
  • Client environment are different from Web, Lynx does not support Web-only features like: CORS、redirect、keepalive related APIs. FormData/Blob related APIs are not supported.

  • Web Platform supports Fetch API using Browser's Fetch implementation, it follows the same rules as the web.

Loading...

Headers

Loading...

Request

Loading...

Response

Loading...

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.