hastebin-gen
v2.0.5
Published
A simple hastebin client for uploading things to hastebin.com
Downloads
2,405
Readme
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");
// You can change the extension by setting the extension option
hastebin("code", { extension: "txt" }).then(haste => {
// Logs the created hastebin url to the console
console.log(haste); // https://hastebin.com/someid.txt
}).catch(error => {
// Handle error
console.error(error);
});
Using async/await
This is assuming that you are in a asynchronous scope
const hastebin = require("hastebin-gen");
// You can change the extension by setting the extension option
const haste = await hastebin("code", { extension: "txt" });
// Logs the created hastebin url to the console
console.log(haste); // https://hastebin.com/someid.txt
Example with a custom haste-server instance
Using .then().catch()
const hastebin = require("hastebin-gen");
// You can change the extension by setting the extension option
hastebin("code", { url: "https://paste.example.com", extension: "txt" }).then(haste => {
// Logs the created hastebin url to the console
console.log(haste); // https://paste.example.com/someid.txt
}).catch(error => {
// Handle error
console.error(error);
});
Using async/await
This is assuming that you are in a asynchronous scope
const hastebin = require("hastebin-gen");
// You can change the extension by setting the extension option
const haste = await hastebin("code", { url: "https://paste.example.com", extension: "txt" });
// Logs the created hastebin url to the console
console.log(haste); // https://paste.example.com/someid.txt