Untitled
unknown
plain_text
2 years ago
521 B
8
Indexable
const axios = require('axios');
const fs = require('fs');
const path = require('path');
async function downloadImage(url, outputPath) {
try {
const response = await axios.get(url, { responseType: 'arraybuffer' });
console.log(response?.data);
fs.writeFileSync(outputPath, response.data);
console.log('Image downloaded successfully:', outputPath);
} catch (error) {
console.error('Error downloading image:', error);
}
}
module.exports = downloadImage;Editor is loading...
Leave a Comment