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
0
votes
1 answer

Cannot figure out how to chain nested promise with Q

I'm new into node.js and promise (Q), so please be kind. I want to chain nested promises with his executing parent chain and i can't find how to. I've made a toy script to illustrate my pb, you can launch it with node.js : var Q =…
Sté
  • 195
  • 11
0
votes
2 answers

Promised Connections Returning Nothing (JS)

Problem with Promised Connections I recently converted my Node app from running on my local machine to utilizing an Amazon EC2 for the Node app and a VPN for the file-serving and MySQL. I learned just enough about Promises to write the following…
user2700923
0
votes
1 answer

Q-promises and error handling

I am trying to understand Q Promises and how to handle two different errors thrown from two different then blocks. Here is the function I would like to "Promisfy": router.post('/user', function(req, res) { var user = new User(req.body); …
Dominic Bou-Samra
  • 14,799
  • 26
  • 100
  • 156
0
votes
1 answer

NodeJS Not Exiting, How to find open handlers?

I have a fairly simple NodeJS script that is not exiting gracefully when done (this is a worker and I want to fire it up using a cron job / heroku scheduler) Once it has finished its task it just sits there waiting. It doesn't use express / a web…
Ryan Knell
  • 6,204
  • 2
  • 40
  • 32
0
votes
1 answer

how to get users names using bluebird?

using bluebird q, I have this: var myBill db.getBillAsync().then(function (bill) { myBill = bill return users.find_user_by_idAsync(bill.user_id) }).then(function (user) { myBill.user_name = user.name console.log(myBill) }) the purpose of the…
AngeloC
  • 3,213
  • 10
  • 31
  • 51
0
votes
2 answers

Javascript Promises/Q - Am I Doing This Right?

I'm trying to use Q within NodeJS to create some amqplib wrappers. The wrappers are working correctly (so far), but I have the feeling my usage of Q is... incorrect. First, there's an initialization method: private static Startup(): void { var…
Michael
  • 4,010
  • 4
  • 28
  • 49
0
votes
1 answer

How to use promises to return the final result of an array?

I am currently trying to return a request of all the file names (in each existing folder) on a particular website. My web application is using NodeJS, Express, Cheerio, and Request to web scrape. My code is first getting a list of all the folder…
user3314402
  • 254
  • 1
  • 3
  • 15
0
votes
1 answer

Is it possible to make a method like Q.spawn return a value in Node JS

I know out of the box Q won't support this, but I'm wondering if it is theoretically possible to do something like this: var user = Q.spawn(function* () { var createdUser = yield createUser(); return user; }); console.log(user); // user is…
Kirk Ouimet
  • 27,280
  • 43
  • 127
  • 177
0
votes
4 answers

Confusion about $q and promises

I have read up on Kris Kowal's Q and angularjs $q variable for a few hours now. But for the life of me I can't figure out how this works. At the moment I have this code in my service: resetpassword: function (email, oldPassword, newPassword) { …
Robin-Hoodie
  • 4,886
  • 4
  • 30
  • 63
0
votes
1 answer

Struggling with Q.js promises

I am sure I am missing something obvious but I can't seem to make heads or tails of this problem. I have a web page that is being driven by javascript. The bindings are being provided by Knockout.js, the data is coming down from the server using…
PlTaylor
  • 7,345
  • 11
  • 52
  • 94
0
votes
2 answers

My error callback is failing with Q Promises

First time trying to use the Q promises library and I can't get my error callback to work: var fs = require('fs'); var Q = require('q'); var prom = Q.nfcall(fs.writeFile('daa/write.txt', 'your mom', 'utf-8')); prom.then(function(err){ …
Amit Erandole
  • 11,995
  • 23
  • 65
  • 103
0
votes
1 answer

How to wait for async angularJS call to complete if concurrent call requested the data being still loaded?

I have an angular service/resource combo that does async call to server to get User Preferences. It is called UserPreferencesService and got a method load: /// UserPreferencesService.load method …
onkami
  • 8,791
  • 17
  • 90
  • 176
0
votes
1 answer

Return a Q Promise from an API Properly

I am developing an API that I would to return a promise. The returned promise is composed of several other promises, so I'm using Q.all and/or Q.allSettled. The problem I'm running into is that the code never completes (see test). I'm expecting to…
binarygiant
  • 6,362
  • 10
  • 50
  • 73
0
votes
1 answer

Testing promises with angularjs order of execution confusion

I'm testing a promise with angularjs jasmine, and sinonjs. I'm puzzled by something regarding promises. Here is my code: it('should return data with length 4 ', inject(function ($rootScope) { var storageData; …
Ivan V.
  • 7,593
  • 2
  • 36
  • 53
0
votes
1 answer

Angular controller promises and testing

Im writing some unit tests for my controller which uses promises. Basically this: UserService.getUser($routeParams.contactId).then(function (data) { $scope.$apply(function () { $scope.contacts = data; }); }); I have mocked my…
user2862639
  • 107
  • 1
  • 1
  • 6