I want to save a Discord user's profile picture on Replit, but even though it downloads successfully, the image is not displaying. Here is the code I am using:
const request = require('request')
const fs = require('fs')
app.get("/get-picture", (req, res) => {
// download the picture from the URL
request.get('https://cdn.discordapp.com/avatars/708947170539339816/cfc4742faa6298e4d8d95070136b6d3a.png', (error, response, body) => {
// save the picture to a file
fs.writeFileSync('picture.png', Buffer.from(body, 'binary'))
})
})
Instead of displaying the image after downloading, only a preview is shown.
I implemented the code above with the expectation that it would display the same image as seen when clicking on the provided link. However, it seems to be showing only the preview instead.