Bun реализует веб-стандартный API fetch для отправки HTTP-запросов. Для отправки простого GET-запроса к URL:
ts
const response = await fetch("https://bun.com");
const html = await response.text(); // HTML-строкаДля отправки POST-запроса к API:
ts
const 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();