You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. This is not really an issue, rather a question.
Can this library be used to synchronously serialize api requests?
The situation is: Given an array of API URL's to fetch (or axios), with the constraint of only one outstanding api request at a time. How to schedule api requests such that request #2 doesn't get sent until response #1 has been received (or timed out).
Turns out this is easy in the node environment, but I haven't been able to figure out how to do it in the browser environment. (Using create-react-app's built in dev server.)
Please provide example if possible. Or pointer to alternate library if more applicable. Thanks in advance.
The text was updated successfully, but these errors were encountered:
Sorry for a very late response. I missed a notification from this old project.
This library is all about extra methods for promise resolutions, not about data serialization.
What you are asking is simply achieved via await/async these days.
b.t.w. In my more recent project, iter-ops, it can be achieved like this:
import{pipeAsync,map,wait}from'iter-ops';constapis=['first uri','second uri'];// your array of URI-sconsti=pipeAsync(apis,map(a=>fetch(a)),// re-map UIR-s into requestswait()// wait for each URI to resolve before making another request);(asyncfunction(){forawait(constaofi){console.log(a);// print response from each individual response}})();
And it works in a browser also.
And it can be improved further, through controlled concurrent resolutions, using waitRace operator.
Hello. This is not really an issue, rather a question.
Can this library be used to synchronously serialize api requests?
The situation is: Given an array of API URL's to fetch (or axios), with the constraint of only one outstanding api request at a time. How to schedule api requests such that request #2 doesn't get sent until response #1 has been received (or timed out).
Turns out this is easy in the node environment, but I haven't been able to figure out how to do it in the browser environment. (Using create-react-app's built in dev server.)
Please provide example if possible. Or pointer to alternate library if more applicable. Thanks in advance.
The text was updated successfully, but these errors were encountered: