Skip to content

Instantly share code, notes, and snippets.

Avatar

Harry Scheuerle hscheuerle

View GitHub Profile
@hscheuerle
hscheuerle / index.js
Last active May 25, 2019
Naming for mongodb driver
View index.js
const { MongoClient: driver } = require('mongodb');
const connectionSpread = [
process.env.DB_URL_DEVELOPMENT || 'mongodb://localhost:27017',
{ useNewUrlParser: true }
];
(async () => {
try {
const client = await driver.connect(...connectionSpread);
@hscheuerle
hscheuerle / request.js
Last active Oct 27, 2018
node.js http request with redirect
View request.js
const handleRequest = async uri => {
return new Promise((resolve, reject) => {
http.get(uri, async res => {
const { statusCode } = res
if (statusCode === 302) { // redirect
const { location } = res.headers
const data = await handleRequest(location)
resolve(data)
You can’t perform that action at this time.