For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/lynx-api/global/fetch.md.
Lynx
  • 简体中文
  • fetch BTS

    语法

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

    参数

    resource

    定义你想要获取的资源。可以是:

    • 一个字符串或任何其他具有字符串化器的对象(包括 URL 对象),提供你想要获取的资源的 URL。

    • 一个 Request 对象。

    options

    一个包含你想要应用到请求上的任何自定义设置的 RequestInit 对象。

    示例

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

    兼容性

    Info
    • 客户端环境与 Web 略有不同,不支持只在 Web 场景下存在的 CORS、redirect、keepalive 相关 API。FormData/Blob 相关 API 暂不支持

    • Web Platform 中的 Fetch API 基于浏览器原生 Fetch 实现,兼容性与浏览器一致

    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

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。