Skip to content

Instantly share code, notes, and snippets.

@ctrlaltdylan
Created November 14, 2020 01:38
Show Gist options
  • Save ctrlaltdylan/fa61bd991b7b1f484bdb15e153755920 to your computer and use it in GitHub Desktop.
Save ctrlaltdylan/fa61bd991b7b1f484bdb15e153755920 to your computer and use it in GitHub Desktop.
Browser Axios Cloudinary Upload
let formData = new FormData();
formData.append("upload_preset", "<your preset from Cloudinary Dashboard here> * Required");
formData.append("file", <instance of a File here>);
axios
.post(
"https://api.cloudinary.com/v1_1/<your Cloudinary cloud name here>/image/upload",
formData,
{
headers: {
"X-Requested-With": "XMLHttpRequest",
},
}
)
.then((res) => {
debugger;
})
.catch((err) => {
console.log(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment