Skip to content

Instantly share code, notes, and snippets.

@dawsbot dawsbot/curl.js
Last active Mar 23, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.