I created REST API using Express JS to send Excel file:
app.get('/download/', async (req, res) => {
try {
await res.download('./ExcelCopy.xlsx');
} catch (e) {
res.status(400).send(e);
}
});
But in Reactjs when I connect to API nothing happens, but redux tells everything went well:
export const getExcel = () => async (dispatch) => {
await dispatch(getExcelRequest());
try {
await axios.get('http://127.0.0.1:8888/download/');
dispatch(getExcelSuccess());
} catch (error) {
console.log(error);
dispatch(getExcelFailed());
}
};
What should I do in order to download a file from back-end using react js