我正在尝试将此代码翻译为与node-fetch
一起使用,但我有点纠结于弄清楚node-fetch
如何转发整个req
比特,因为它包含了我想要上传的文件。
async function handler(req, res) {
let uploadPhotoAddress = baseURL + "/upload";
if (req.method == "POST") {
const { data } = await axios.post(uploadPhotoAddress, req, {
responseType: "stream",
headers: {
"Content-Type": req.headers["content-type"], // which is multipart/form-data with boundary included
apikey,
},
});
data.pipe(res);
} else {
return res.status(405).json({ message: "Method Not Allowed" });
}
}
暂无答案!
目前还没有任何答案,快来回答吧!