Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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