I'm trying to save an image using node's file-system that I got from https://picsum.photos/ but the file that is getting written is not what I'm expecting it to be.
const axios = require('axios');
const path = require('path');
const fs = require('file-system');
axios.get('https://picsum.photos/id/237/200/300')
.then((data) => {
fs.writeFile(path.resolve(__dirname, '../assets/test/test1.jpg'), data.data, (err) => {
if (err) {
console.log(err);
throw err;
}
console.log('file save successfully');
});
})
.catch((err) => {
console.log(err);
});