How to run an API request as a background function to avoid timeout
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
I am hitting an external API endpoint from my Next app that takes upwards of 2 minutes to intake POST data and send back a response. My nextjs Serverless Functions are timing out because they're expecting a 30 second response time.
Is there a way to run a function in the background, so the user doesn't have to wait? It would wait for the external API response then save that info to a DB.
Is there a way to run a function in the background, so the user doesn't have to wait? It would wait for the external API response then save that info to a DB.
4 Replies
@Sun bear I am hitting an external API endpoint from my Next app that takes upwards of 2 minutes to intake POST data and send back a response. My nextjs Serverless Functions are timing out because they're expecting a 30 second response time.
Is there a way to run a function in the background, so the user doesn't have to wait? It would wait for the external API response then save that info to a DB.
i think you have to use an external service or a separate server for this; serverless is not designed for this use case
Sun bearOP
That's what I was assuming... Any recommendations for an external service to use?
i have never needed to do this so idk
but about a separate server, you can find one very easily at a few bucks a month