Questions tagged [q]

The Q.js JavaScript promise library. Q catches errors and uses a `then` technique to handle JavaScript callbacks and exceptions. Do *not* use for Angular's $q, use [angular-promise] instead! Also do *not* use for kx System's kdb+/q, use [kdb] or [q-lang] instead! Lastly, this tag should not be used for questions regarding Android 10 - use the [android-10.0] tag instead!

A JavaScript library for the browser and Node.js for making and composing asynchronous promises. Q catches errors and uses a then technique to handle JavaScript callbacks and exceptions.

1381 questions
-1
votes
1 answer

add a delay(synchronous) working with modern browsers except IE

Working code: in Chrome, Firefox let sleep = function (ms) { return new Promise(resolve => setTimeout(resolve, ms)) }; And somewhere in my function i use async,await to make the delay synchronous function updateHandler(newTags, tagName,…
ggorantala
  • 196
  • 2
  • 16
-1
votes
1 answer

Q: Promise Chaining and Rejection: Doesn't reject kill the chain?

I have the following chained functions that all implement promises utilizing Q: validateToken(context).then(parseFormData, get403).then(createReport, get400).then(send200, get400).catch(get500); e.g. All of them have somewhere within them: let…
Doug
  • 6,446
  • 9
  • 74
  • 107
-1
votes
1 answer

Best way to handle the nodejs promise

I am new to nodejs and promises. This is code I wrote by reading some articles but I feel I am not on correct path. Issue:- In getManager() sometimes neo4j db throws an error while running a query so control ends up in catch block. However, somehow…
Royjad
  • 99
  • 3
  • 13
-1
votes
1 answer

JavaScript: Recursive Async / Promise Based Function

I have the following recursive function that works beautifully when the output from transformItem is synchronous, but I've been having a very difficult time figuring out how to refactor it when transformItem returns a a promise and still get the…
Doug
  • 6,446
  • 9
  • 74
  • 107
-1
votes
2 answers

Cannot read property 'apply' of undefined Q.js

I am trying to populate Array asynchronously with data captured from MongoDB. I have a set of functions, which should execute one by one to merge 2 results from different tables into one, but upon execution, error is porduced: TypeError: Cannot read…
Marks Gniteckis
  • 473
  • 1
  • 6
  • 18
-1
votes
1 answer

Wait a result from a API using nodejs

I'm quite new to Node.js. I would like to call an API and wait the result before to do something. // endpoint function getListMarket() { var deferred = Q.defer(); deferred.resolve(Q().then(getMarkets) .then(calculIndicators)); return…
holegeek
  • 97
  • 2
  • 12
-1
votes
1 answer

AngularJS $q service response in sequence with exception handling

I have a function which gives me response in sequence for asynchronous call using promises for a for loop but loop breaks when i got a exception from code, but i want to continue my loop even after a exception throw from function. my async function…
Gaurav Kumar Singh
  • 1,550
  • 3
  • 11
  • 31
-1
votes
1 answer

purpose of $q service in angular?

I am not able to understand the use of $q service in angular js. Can some one please give elaboration on this topic that what is the $q service in angularjs? How can we use that
Sheetal
  • 29
  • 3
-1
votes
1 answer

Node promises: use first/any result (Q library)

I understand using the Q library it's easy to wait on a number of promises to complete, and then work with the list of values corresponding to those promise results: Q.all([ promise1, promise2, . . . …
Gershom Maes
  • 7,358
  • 2
  • 35
  • 55
-1
votes
1 answer

how to add $q to order the execution?

I need to order my execution. I need to make sure my COMPLETE coords() method finishes, once it is called. how to add a promise or $q to it? I tried printing on console and found forEach loop in coords is completed after the last line of coords()…
nemo asad
  • 11
  • 4
-1
votes
1 answer

then of promise not waiting for result to return

Following are the functions in node.js using promise. exports.getDetailsByUserId = function(req,res) { getUserDetails(req, res) // function to get user details .then(function (Details) { var allpromises = Details.map(getStatus);…
sam
  • 3
  • 2
  • 4
-1
votes
1 answer

Q.all() not returning array of resolved values

I have a somewhat complicated scenario and I'm not quite understanding why my call to Q.all is not returning an array of resolved promises. It is a mix of jQuery $.ajax calls and Q. calls. Here is the setup: var saveThing1 = function(){ return…
Joel Kinzel
  • 969
  • 2
  • 7
  • 19
-1
votes
1 answer

Recursive function in node.js using q library

I need to prepare JSON by fetching the data from MYSQL. I have data in MYSQl in tree structure. I am trying to make recursive function to prepare JSON to meet the requirement but getting errors, I have following two files main.js /* jshint node:…
Jatin Seth
  • 312
  • 1
  • 4
  • 19
-1
votes
1 answer

Express with Q deferred not responding to requests

I'm trying to use a node backend with my angular script using Q to promise-fy an fs method. Using the normal callback method works, however here, nothing is returned to Angular. Nothing is printed in the console, and no error is returned in the…
1252748
  • 14,597
  • 32
  • 109
  • 229
-1
votes
1 answer

How to implement set of async task with some condition in series?

I have to write the following code in nodejs: val1 = async1() if(val1 == 0){ val1 = async2() } val2 = async3(val1) In the above code, val1 and val2 are the values returned from asyncronous functions async1(), async2() and async3() How can I…
Vishal
  • 467
  • 1
  • 8
  • 17