Skip to content

Instantly share code, notes, and snippets.

@dawsbot
Last active March 23, 2017 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawsbot/cdbb73b5937d01a145097e73a4b7dca7 to your computer and use it in GitHub Desktop.
Save dawsbot/cdbb73b5937d01a145097e73a4b7dca7 to your computer and use it in GitHub Desktop.
es6AF way to curl to tempfile
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