Skip to content

Instantly share code, notes, and snippets.

@arn4v
arn4v / fetchretry.js
Created February 17, 2021 15:58
Simple requestretry
/**
* @param {RequestInfo} opts
* @param {number} maxRetries
* @param {number} retryDelay
*/
const fetchRetry = async (opts, maxRetries, retryDelay) => {
let error
for (let i = 0; i < maxRetries; i++) {
try {
if (i > 0) {
@arn4v
arn4v / dotenv.js
Created February 11, 2021 06:55
Simple dotenv for NodeJS
const path = require("path")
const ROOT = process.cwd()
const ENV_PATH = path.resolve(path.join(ROOT, ".env"))
module.exports.dotenv = function dotenv() {
fs.readFileSync(ENV_PATH)
.toString()
.split("\n")
.filter((i) => i.length > 0)
.forEach((i) => {