Skip to content

يطبق Bun واجهة برمجة التطبيقات 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: "مرحبًا من Bun!" }),
  headers: { "Content-Type": "application/json" },
});

const body = await response.json();

Bun بواسطة www.bunjs.com.cn تحرير