Last active
March 23, 2017 22:32
-
-
Save dawsbot/cdbb73b5937d01a145097e73a4b7dca7 to your computer and use it in GitHub Desktop.
es6AF way to curl to tempfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = 'https://google.com'; | |
const pify = require('pify'); | |
const fs = pify(require('fs')); | |
const fetch = require('node-fetch'); | |
const tempfile = require('tempfile'); | |
const curl = (package, version) => { | |
fetch(url) | |
.then(res => res.text()) | |
.then(res => { | |
const tmpFile = tempfile(); | |
fs.writeFile(tmpFile, res, 'utf-8') | |
.then(res => { | |
console.log('tmpFile: ', tmpFile); | |
}); | |
}) | |
} | |
curl(url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment