Skip to content

Instantly share code, notes, and snippets.

@newvertex
Created March 8, 2017 10:01
Show Gist options
  • Save newvertex/f8063899c284fd1b0260a9ac8c275575 to your computer and use it in GitHub Desktop.
Save newvertex/f8063899c284fd1b0260a9ac8c275575 to your computer and use it in GitHub Desktop.
Upload image file from browser to imgur
const API = 'https://api.imgur.com/3/upload';
const CLIENT_ID = `Client-ID xxxxxxxxxxxxxxx`; // Get client-id from imgur: https://api.imgur.com/oauth2/addclient
function upload(file) {
let data = new FormData();
data.append('image', file);
return fetch(
API,
{
method: 'POST',
headers: {
Authorization: CLIENT_ID,
},
body: data,
}
);
}
export default upload;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment