const res = await axios.get(url, {
responseType: 'arraybuffer',
headers: {
'Content-Type': 'image/jpg'
},
params: {aspect: 0.8}
)
const res2 = await fs.promises.writeFile(`image.jpg`, res.data)
axios.get(url, {
responseType: 'arraybuffer',
headers: {
'Content-Type': 'image/jpg'
},
params: {aspect: 0.8}
).then(res => {
fs.writeFile(`image.jpg`, res.data, (err) => {
if(err) throw err
console.log('saved')
})
})