@glennsl/rescript-fetch

中文文档
0.3.0发布于 2026/05/02MIT零依赖近 30 天下载 2.7万

Zero-cost rescript bindings to the WHATWG Fetch API

原始使用文档
文档目录11 节
  1. Example
  2. Installation
  3. Documentation
  4. API
  5. Changes
  6. 0.3.0
  7. 0.2.3
  8. 0.2.2
  9. 0.2.1
  10. 0.2.0
  11. 0.1.0

rescript-fetch

Zero-cost rescript bindings to the WHATWG Fetch API

npm Issues Last Commit

Example

let postBanana = async data => {
  open Fetch

  let response = await fetch(
    "/api/bananas",
    {
      method: #POST,
      body: data->JSON.stringifyAny->Option.getOrThrow->Body.string,
      headers: Headers.fromObject({
        "Content-type": "application/json",
      }),
    },
  )

  await response->Response.json
}

See examples for more.

Installation

npm install --save @glennsl/rescript-fetch

Then add @glennsl/rescript-fetch to dependencies in your rescript.json:

 {
   "dependencies": [
+    "@glennsl/rescript-fetch"
   ]
 }

Documentation

API

For the moment, please see the interface file:

Changes

0.3.0

  • [BREAKING] Updated required minimum version of rescript to 12.
  • Replaced bsconfig.json with rescript.json and switched module spec to esmodule.
  • Migrated from Js.Json.t/Js.Array.array_like to the rescript 12 standard library (JSON.t, Iterator.t).

0.2.3

  • Added Headers.getSetCookie

0.2.2

  • Fixed typo in Request.credentials binding.

0.2.1

  • Fleshed out AbortSignal bindings.

0.2.0

  • [BREAKING] Updated required minimum version of rescript to 10.1.2 in order to use the new promise type alias and async/await.
  • Removed @ryyppy/rescript-promise dependency.

0.1.0

Initial release

版本与发布记录

@glennsl/rescript-fetch 共发布 10 个版本,首次发布于 2022/08/14;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.3.0latest2026/05/026 个月前
0.2.32024/11/302 年前
0.2.22024/08/192 年前
0.2.12024/07/212 年前
0.2.02023/02/183 年前
0.1.42022/08/284 年前

关于 @glennsl/rescript-fetch 的常见问题

@glennsl/rescript-fetch 是什么?

Zero-cost rescript bindings to the WHATWG Fetch API

如何安装 @glennsl/rescript-fetch?

在项目目录运行 npm install @glennsl/rescript-fetch,或使用 pnpm add / yarn add / bun add。

@glennsl/rescript-fetch 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/glennsl__rescript-fetch 是否存在。

@glennsl/rescript-fetch 可以商用吗?

@glennsl/rescript-fetch 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@glennsl/rescript-fetch 的下载量有多少?

根据 npm 官方下载统计,@glennsl/rescript-fetch 在 2026/10/17 – 2026/11/15 这 30 天内被下载 27,491 次,日均约 916 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@glennsl/rescript-fetch 还在维护吗?

最新版本 0.3.0 发布于 2026/05/02(6 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/08/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。