Created
April 12, 2022 21:33
-
-
Save AbeEstrada/5d43b18c0ee6b3dc519b4393f07c98c4 to your computer and use it in GitHub Desktop.
Node axios download image
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
import { writeFile } from "fs/promises"; | |
import axios from "axios"; | |
const main = async () => { | |
try { | |
const response = await axios.get(`${FILE_URL}`, { responseType: "arraybuffer" }); | |
try { | |
await writeFile(`./${FILE_NAME}.jpg`, response.data); | |
} catch(err) { | |
console.log(err); | |
} | |
} catch(err) { | |
console.log(err); | |
} | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment