Trying to create a rest api that processes excel data. I want to let the client know that the files have been received.
app.post('/upload',upload.fields([{name: 'raw'},{name: 'report'}]), (req: any, res: any)=>{
res.send(statuscode 200)
// do async excel operations
return res.json({data: data});
})
I don’t want to send a response after the client has been waiting for 30 seconds
await excelOperations();
return res.json()
2
Answers
With the traditional HTTP request-response model, you don’t. You send the acknowledgement as the response to the data submission, when the upload has completed. Then the client makes another request (or even multiple ones) to inquire about the status of the processing, which you respond to with a progress report response each, and finally the client makes another request to download the results, to which you respond with the processed resource.
You could however use server-sent events or websockets which would allow you to send multiple things as long as the connection is open.
To complete Bergi answer you can do something like that :
Code example