I'm getting binary file from a remote server, but I am unable to correctly store it locally using the file system. When I try to open the saved file, it shows as incorrect format etc and doesn't open the file. However, If I download the file directly from the site, it works fine. Need help on this. Thanks!
const fileData = await axios({ //this returns binary data.
method: "get",
url: instanceURL,
headers: {
"Authorization": "Bearer " + token,
},
});
fs.writeFileSync(storePath, Buffer.from(fileData.data, "binary"));