Created
August 28, 2021 09:33
-
-
Save hoyangtsai/881a10bc59ef8f79d3290f10ff696086 to your computer and use it in GitHub Desktop.
nodejs imgur upload
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
// register an application | |
// https://api.imgur.com/oauth2/addclient | |
// get registered apps info | |
// https://imgur.com/account/settings/apps | |
const imgur = require('imgur'); | |
imgur.setClientId(`${CLIENT_ID}`); | |
imgur | |
.uploadFile(`${filePath}`) | |
.then((resp) => { | |
// console.log(`resp: ${JSON.stringify(resp, null, 4)}`); | |
// image link | |
const { link } = resp; | |
}) | |
.catch((err) => { | |
console.error('imgur error:', err.message); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment