Untitled
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;
Leave a Comment