相关文章推荐
无聊的猕猴桃  ·  意大利国家概况·  1 年前    · 
爱喝酒的日光灯  ·  上海静安宝山路街道社区服务中心上线随心查系统 ...·  1 年前    · 
气势凌人的核桃  ·  人民周刊·  1 年前    · 
豪气的西瓜  ·  人民文摘·  2 年前    · 
坏坏的猕猴桃  ·  《寻找身体》高清下载-电影-夕阳小站·  2 年前    · 
Code  ›  Send an HTTP request using fetch | Bun Examples
fetch
https://bun.sh/guides/http/fetch
精明的菠菜
10 月前
Bun logo Bun Bun

Search the docs...

/

    Bun
    Build Docs Reference Guides Blog
    Discord logo Discord logo
    Discord
    GitHub logo GitHub logo
Bun v1.2.18
ReadableStream text(), json(), bytes(), blob(), WebSocket client compression with `permessage-deflate`, `bun pm version`, reduced memory usage f...
Bun v1.2.17
Ahead-of-time bundling for HTML imports, more reliable Bun Shell, `setTimeout` and `setImmediate` use 8-15% less memory, `columnTypes` & `declar...
Bun v1.2.16
Serve files with `Bun.serve` through `routes`, `install.linkWorkspacePackages` option in `bunfig.toml`, `bun outdated` support for catalogs, `Bu...
Bun v1.2.15
bun audit scans dependencies for security vulnerabilities, bun pm view shows package metadata from npm. bun init adds a Cursor rule to use Bun i...
Bun v1.2.14
Adds support for catalogs in bun install, --react flag for bun init, improved HTTP routing with method-specific routes, better TypeScript defaul...
Bun v1.2.13
Improved --hot stability and Node.js compatibility. Better `node:worker_threads` support, environment data, reduced memory usage for child_proce...
Build Docs Reference Guides Blog
Discord logo Discord logo
Discord
GitHub logo GitHub logo

Guides HTTP

Send an HTTP request using fetch with Bun

GitHub logo GitHub logo

Edit on GitHub

Bun implements the Web-standard fetch API for sending HTTP requests. To send a simple GET request to a URL:

const response = await fetch("https://bun.sh");
const html = await response.text(); // HTML string

To send a POST request to an API endpoint.

const response = await fetch("https://bun.sh/api", {
  method: "POST",
  body: JSON.stringify({ message: "Hello from Bun!" }),
 
推荐文章
无聊的猕猴桃  ·  意大利国家概况
1 年前
爱喝酒的日光灯  ·  上海静安宝山路街道社区服务中心上线随心查系统- 上海本地宝
1 年前
气势凌人的核桃  ·  人民周刊
1 年前
豪气的西瓜  ·  人民文摘
2 年前
坏坏的猕猴桃  ·  《寻找身体》高清下载-电影-夕阳小站
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号