At backend, I have the following NodeJS script:
app.get('/getDownloadTemplate', cors(), (req, res) => {
res.sendFile(path.join(__dirname, '../temp.xlsx'));
});
At frontend, I have React code like this:
axios.get('http://127.0.0.1:3000/getDownloadTemplate').then((response) => {
return response;
});
When I manually paste http://127.0.0.1:3000/getDownloadTemplate on the chrome, the file temp.xlsx is automatically downloaded to my Downloads folder.
But when I try to download via React, nothing happens.
Can anyone help me?