I'm working with an API that requires info requests to be made one at a time. If there's multiple requests, I'd like to make an attempt to get them all, but it's an all or nothing situation. If we don't get them all after 2 seconds, move to the next step without them.
I know this is possible using promises, but I keep getting the behavior to either way for them, or forcibly wait 2 seconds, even if it has them all after 1.
Any advice or guidance would be greatly welcome.
Also, it adds the info to a store, so it would be best the api call running in the background to get that info regardless of if the next stage got access to it.
- Payload comes in with key array
- I begin a recursive function to ping API for keys one at a time
- If not all keys are back after 2 seconds, continue the payload to the next step
- Continue the key storing process even if it passes 2 seconds
- If are back early, do not wait for the full 2 seconds
Thanks in advance, truly appreciate any help or implementation suggestions.