Skip to content Skip to sidebar Skip to footer
Showing posts with the label Promise

Promise Returning Undefined

I am trying to use promise to send an ajax request to a php script which checks if a file exist on … Read more Promise Returning Undefined

How To Sequentially Handle Asynchronous Results From Api?

This question might be a little vague, but I'll try my best to explain. I'm trying to creat… Read more How To Sequentially Handle Asynchronous Results From Api?

Promise.all([]) Returns A Resolved Promise, But Promise.race([]) Returns A Pending Promise. Why Are They Different?

If either Promise.all or Promise.race are called with a non-empty array, they return a pending prom… Read more Promise.all([]) Returns A Resolved Promise, But Promise.race([]) Returns A Pending Promise. Why Are They Different?

How To Reuse A Mongo Connection With Promises

How can I change things around in my db connection call so that I can do db.collection(): // Create… Read more How To Reuse A Mongo Connection With Promises

Wrapping Jquery $.ajax Behind A Facade In Q.js Without Refactoring

It's possible this should be on code review, but here we go! I have a fairly large application … Read more Wrapping Jquery $.ajax Behind A Facade In Q.js Without Refactoring

Javascript Promise Pattern - Differentiate Error

Consider this block of code: getUser(userId) .catch(function(error){ crashreporter.… Read more Javascript Promise Pattern - Differentiate Error

Changing My Callbacks, Promise To Async Await

My code: Callbacks: const first = () => { console.log('first'); }; const second = (cal… Read more Changing My Callbacks, Promise To Async Await

Javascript - Iterate An Array And Call Jquery Ajax Requests And Wait For A Request Finished Before Moving To Next Request?

I need to iterate an array (or a simple for loop) to run Ajax request to a server. The problem is, … Read more Javascript - Iterate An Array And Call Jquery Ajax Requests And Wait For A Request Finished Before Moving To Next Request?

Chaining 2 Asynchronous Calls (promise Api) To Run Serially

This is similar to a question I posted today, but needs the request chained serially. I have two as… Read more Chaining 2 Asynchronous Calls (promise Api) To Run Serially

How To Know When All Promises Are Resolved In A Dynamic "iterable" Parameter?

My problem is that I don't know how to know when a dynamic promise array has all the promises r… Read more How To Know When All Promises Are Resolved In A Dynamic "iterable" Parameter?

How To Properly Catch Errors In Promises?

I am under the impression that these two things are not equivalent: return somePromise() .then() … Read more How To Properly Catch Errors In Promises?

Promise Chain .then .catch

How does work this promise chain? Promise.resolve(1) .then(x => console.log(1)) .catch(x =&g… Read more Promise Chain .then .catch

Angularjs : Chaining Promises

Following the suggestions from AngularJS validation and promises, I would like to chain confirmatio… Read more Angularjs : Chaining Promises

How Can I Make A Promise Reject For Testing?

I have a db.js set up to do all my database calls. This is an example of one of the functions that … Read more How Can I Make A Promise Reject For Testing?

Can I Use $q.all In Angularjs With A Function That Does Not Return A .promise?

If I have the following functions: doTask1: function ($scope) { var defer = $q.defer(); … Read more Can I Use $q.all In Angularjs With A Function That Does Not Return A .promise?

Promise.all() - How To Resolve() Without Returning Undefined Or Value

I want to use Promise.all() to check if a value is in an array. My problem is when the value is not… Read more Promise.all() - How To Resolve() Without Returning Undefined Or Value

How To Reject Promise On D3 Xhr Request Timeout?

I want to set a timeout value so that if the server does not respond in that particular time frame … Read more How To Reject Promise On D3 Xhr Request Timeout?

Ensuring Asyncronous '.then()' Execution In Compound Promises

I am using Typescript to write JS promises. I have a compound promise, i.e. promise which returns a… Read more Ensuring Asyncronous '.then()' Execution In Compound Promises

Js Promise - Instantly Retrieve Some Data From A Function That Returns A Promise

Can anyone recommend a pattern for instantly retrieving data from a function that returns a Promise… Read more Js Promise - Instantly Retrieve Some Data From A Function That Returns A Promise

Executing Promises In Array With Promise.all Breaks Them

I have an array of userIds that I use in getOrdersByUserId() to get the orders placed by these user… Read more Executing Promises In Array With Promise.all Breaks Them