Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
Created April 12, 2022 21:33
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 AbeEstrada/5d43b18c0ee6b3dc519b4393f07c98c4 to your computer and use it in GitHub Desktop.
Save AbeEstrada/5d43b18c0ee6b3dc519b4393f07c98c4 to your computer and use it in GitHub Desktop.
Node axios download image
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