執行環境套件管理器打包器測試執行器程式碼檢查格式化指南參考部落格意見回饋

將 Response 寫入檔案

使用 Bun.write() 將 Response 寫入磁碟。Bun 會將 Response 的正文寫入目標位置。

第一個引數是_目標位置_,例如絕對路徑或 BunFile 例項。第二個引數是要寫入的_資料_。

TypeScript
const result = await fetch("https://bun.sh");
const path = "./file.txt";
await Bun.write(path, result);

請參閱 Bun.write()。