My application is in react and calls the node
layer via axios
call. The node
layer then calls an external api
which takes around 7 mins to respond. However i get a timeout error in about 2-3 mins from the time the request was made.When i call the external api
directly (not via node layer ) i am able to get the response in 7 mins. I have tried setting timeout
for node
using the suggestions like
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello World");
}).on('connection', function(socket) {
socket.setTimeout(200000000);
}).listen(3000);
and also using server.timeout but nothing seems to work. Can someone suggest on how to resolve the issue.
I am getting the following error
Network Error at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16:15
I am using axios
axios.post('/api/parseAndExtractFile', formData, config)
.then((response) => {
if (response.status === 200) {
const fileName = `enriched_v3_spec_${new Date().getTime()}`
const blob = new Blob([(response.data)], {type: 'application/vnd.ms-excel.sheet.macroEnabled.12'})
saveAs(blob, fileName)
} else {
toast.error('Oops, something went wrong. Please try again.', {autoClose: 4000})
}
this.setState({
loading: false,
showAuditLog: 'show'
})
})
.catch((error) => {
this.setState({loading: false})
toast.error(`Error while fetching data ${error}`, {autoClose: 4000})
})