Created
March 8, 2017 10:01
-
-
Save newvertex/f8063899c284fd1b0260a9ac8c275575 to your computer and use it in GitHub Desktop.
Upload image file from browser to imgur
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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