Skip to content

Instantly share code, notes, and snippets.

// npm i axios
const axios = require('axios').default;
axios.interceptors.request.use( x => {
// to avoid overwriting if another interceptor
// already defined the same object (meta)
x.meta = x.meta || {}
x.meta.requestStartedAt = new Date().getTime();
return x;
@JonathonJulian
JonathonJulian / gist:d8f50d89fd777ea9a19e917f64f830ab
Created November 28, 2018 22:25 — forked from AndrewRayCode/gist:825583
recursive read directory in node.js returning flattened list of files and directories
function readDir(start, callback) {
// Use lstat to resolve symlink if we are passed a symlink
fs.lstat(start, function(err, stat) {
if(err) {
return callback(err);
}
var found = {dirs: [], files: []},
total = 0,
processed = 0;
function isDir(abspath) {