[Fixed] How cache and execute in nodejs a call

Issue

I have an application that it’s gathering data from another application, both in NodeJS.

I was wondering, how can I trigger sending the data to a third application on certain conditions? For example, every 10 mins if there’s data in a bucket or when I have 20 elements to send?
And if the call on the third parties fails, how can I repeat it after 10-15 mins?

EDIT:
The behaviour should be something like:

if you have 1 data posted (axios.post) AND [10 mins passed OR other 10 data posted] SUBMIT to App n.3
What can help me doing so? Can I keep the value saved until those requirements are satisfied?
Thank you <3

Solution

You can use packages like node-schedule which is popular to schedule tasks. When callback runs check if there is enough data(posts) to send.

Leave a Reply

(*) Required, Your email will not be published