gittart.pages.dev




Combine result from two async requests javascript


Subscribe to RSS

You could use promises for that. Although as stated here deffered is obsolete, but i couldn't find an easy way to make it using the new promise api. Yeah, but I'm not issuing two post requests, but answering them. Post as a guest Name. Create a free Team Why Teams? Stack Overflow for Teams — Start collaborating and sharing organizational knowledge.

Connect and share knowledge within a single location that is structured and easy to search. So I do not have the common scope where both promises live to combine the promises like you can in the last 3 lines of your code — Perseids. Learn more about Teams. Since you separated your code into two functions, you'll probably need to call them when needed, e. Sorted by: Reset to default.

Asynchronous - how to assemble results of async requests in javascript - Stack Overflow

Uh, sorry, I'm on the other side, in the node. Browse other questions tagged javascript node. The db element would just need the id, data1 and data2. Promises work on both sides and should be supported by newer versions of Node. The Overflow Blog. On receipt of the post you can register the Id in a database. Email Required, but never shown. Asked 7 years, 6 months ago.

javascript - Combine data of two async requests to answer both requests - Stack Overflow

Highest score default Trending recent votes count more Date modified newest first Date created oldest first. I'm trying to bring together two async data sources each of them arrive at my server via a POST request and have a common, otherwise unique ID. What data structure, library etc. Not the answer you're looking for? Find centralized, trusted content and collaborate around the technologies you use most. Then after registering the id and the appropriate data you'd call a setTimout in your handler that checks the db element for both data1 and data2.

Sign up using Email and Password. Viewed 2k times. Perseids Perseids Add a comment.

combine result from two async requests javascript

Combine data of two async requests to answer both requests Ask Question. Community Bot 1 1 1 silver badge. This code uses callbacks and it could be edited to use Deffered promises. Modified 6 years, 8 months ago.

Asynchronous - how to assemble results of async requests in javascript - Stack Overflow

To illustrate my problem with code: I have two functions, let's call them back and front , that are called at arbitrary times:. Learn more about Collectives. Sign up using Facebook. Let us continue this discussion in chat. Sign up or log in Sign up using Google. They could return the promise so you could write front. Alex Michailidis Alex Michailidis 4, 1 1 gold badge 16 16 silver badges 35 35 bronze badges.

I have made the assumption that id is an alphanumeric and it can be a property of an object.