Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Created August 28, 2021 09:33
Show Gist options
  • Save hoyangtsai/881a10bc59ef8f79d3290f10ff696086 to your computer and use it in GitHub Desktop.
Save hoyangtsai/881a10bc59ef8f79d3290f10ff696086 to your computer and use it in GitHub Desktop.
nodejs imgur upload
// 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