Documentation Index
Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
Bun 实现了 Web 标准的 fetch API 用于发送 HTTP 请求。要向一个 URL 发送一个简单的 GET 请求:
fetch.tsconst response = await fetch("https://bun.com");
const html = await response.text(); // HTML 字符串
向 API 端点发送 POST 请求。
fetch.tsconst response = await fetch("https://bun.com/api", {
method: "POST",
body: JSON.stringify({ message: "Hello from Bun!" }),
headers: { "Content-Type": "application/json" },
});
const body = await response.json();