I'm trying to translate this code to work with node-fetch
but I'm kinda stuck in figuring out how the node-fetch
can forward the whole req
bit since it's the one that contains the file I want to upload.
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" });
}
}