hastebin-gen
A npm module for generating hastebin links.
https://www.npmjs.com/package/hastebin-gen
Installation
NPM: npm i hastebin-gen
Yarn: yarn add hastebin-gen
Options
Option | Type | Default Value |
---|
url | string | "https://hastebin.com" |
extension | string | "js" |
Examples
Using .then().catch()
const hastebin = require("hastebin-gen");
hastebin("code", { extension: "txt" }).then(haste => {
console.log(haste);
}).catch(error => {
console.error(error);
});
Using async/await
This is assuming that you are in a asynchronous scope
Understanding Async/Await
const hastebin = require("hastebin-gen");
const haste = await hastebin("code", { extension: "txt" });
console.log(haste);
Example with a custom haste-server instance
Using .then().catch()
const hastebin = require("hastebin-gen");
hastebin("code", { url: "https://paste.example.com", extension: "txt" }).then(haste => {
console.log(haste);
}).catch(error => {
console.error(error);
});
Using async/await
This is assuming that you are in a asynchronous scope
Understanding Async/Await
const hastebin = require("hastebin-gen");
const haste = await hastebin("code", { url: "https://paste.example.com", extension: "txt" });
console.log(haste);