Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
521 B
1
Indexable
Never
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