Last active
October 27, 2021 14:09
-
-
Save bhuizi/c38ae195172766d90e2aaf5e1f023672 to your computer and use it in GitHub Desktop.
axios get request w/ piping
This file contains 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 axios = require('axios'); | |
const fs = require('fs'); | |
const url = <path_to_file> | |
axios({ | |
method: 'get', | |
url: url, | |
responseType:'stream' | |
}) | |
.then(res => { | |
res.data.pipe(fs.createWriteStream('new.zip')); | |
}) | |
.catch(err => console.log(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment