Skip to content

Bun implementa a API fetch padrão Web para enviar requisições HTTP. Para enviar uma simples requisição GET para uma URL:

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

Para enviar uma requisição POST para um endpoint de 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();

Bun by www.bunjs.com.cn edit