Bun 은 HTTP 요청을 보내기 위한 Web 표준 fetch API 를 구현합니다. URL 에 간단한 GET 요청을 보내려면:
ts
const response = await fetch("https://bun.com");
const html = await response.text(); // HTML 문자열API 엔드포인트에 POST 요청을 보내려면:
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();