$fetch

How do I add FormData (containing uploaded images) in a $fetch post request? I have gone through the documentation nothing was said about this. I just want to send the image to the backend api to upload it. I usually use axios for this but the nuxt offical documentation recommends using $fetch.
2 Replies
manniL
manniL2y ago
@TechieStephen e.g.:
const formData = new FormData();
formData.append("file", file);
return await $fetch('/api/upload', {
method: "POST",
body: formData,
});
const formData = new FormData();
formData.append("file", file);
return await $fetch('/api/upload', {
method: "POST",
body: formData,
});
TechieStephen
TechieStephenOP2y ago
thanks so much though i ended up using axios but I will try this out
Want results from more Discord servers?
Add your server