Skip to content

Instantly share code, notes, and snippets.

@deguchi
Created June 25, 2021 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deguchi/1e2a9579a6f9c058dfac06e4fe0e79b8 to your computer and use it in GitHub Desktop.
Save deguchi/1e2a9579a6f9c058dfac06e4fe0e79b8 to your computer and use it in GitHub Desktop.
'use strict'
const fs = require('fs');
require('dotenv').config()
const Gyazo = require('gyazo-api');
const client = new Gyazo(process.env.GYAZO_TOKEN);
const gyazo = async (path) => {
return new Promise((resolve, reject) => {
client.upload(path, {
title: "screenshot",
desc: "upload from nodejs"
})
.then((res) => {
// console.log(res.data.image_id);
// console.log(res.data.permalink_url);
resolve(res.data.permalink_url)
})
.catch((err) => {
console.error(err);
reject(err);
});
});
}
module.exports = gyazo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment