#$fetch

2 messages · Page 1 of 1 (latest)

median osprey
#

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.

spare ingot
#

@median osprey e.g.:

  const formData = new FormData();
    formData.append("file", file);
    return await $fetch('/api/upload', {
      method: "POST",
      body: formData,
    });