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

:::Caution Differences from Web

  • Client environment are different from Web, Lynx does not support Web-only features like: CORS、redirect、keepalive related APIs

  • Streaming/FormData/Blob related APIs are not supported

:::

:::Warning Web Platform Compatibility

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

:::

LCD tables only load in the browser

Headers

LCD tables only load in the browser

Request

LCD tables only load in the browser

Response

LCD tables only load in the browser

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.