Send image with fetch API

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the javascript category.

Last Updated: 2024-03-05

// Create a form data entity
const formData = new global.FormData();
  "image", {name: "image.jpeg", type: "image/jpg", uri: imageUri}

return fetch(url, {
  method: "POST",
  // Needs this header
  headers: {
    "Content-Type": "multipart/form-data",
  body: formData