Skip to content

Instantly share code, notes, and snippets.

@DavyBello
Created July 27, 2018 21:09
Show Gist options
  • Save DavyBello/4f900714f5e75ad9790622056bdcab43 to your computer and use it in GitHub Desktop.
Save DavyBello/4f900714f5e75ad9790622056bdcab43 to your computer and use it in GitHub Desktop.
const uploadPreset = 'yxp8krwl';
const cloudName = 'dgq5corvs';
let file; //from upload button
const formData = new FormData();
formData.append('file', file);
formData.append('upload_preset', uploadPreset);
try {
const response = await axios.post(
`https://api.cloudinary.com/v1_1/${cloudName}/image/upload`,
formData,
);
console.log(response);
//do api post to save file details to db
} catch (e) {
console.log(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment