Bluebird: [TypeError: expecting an array or an iterable object but got [object Null]]

Created on 17 Mar 2016  路  2Comments  路  Source: petkaantonov/bluebird

when I use Promise.spread(), I got this err.

Here is my code:

Promise = require 'bluebird'
request = Promise.promisifyAll(require 'request')
request.postAsync(options)
.spread (resp, body) ->
console.log "resp----->",resp
console.log "body----->",body
.catch (err) ->
console.log err
It goes to catch and console log err.If I use .then ,it works well.
I can get the 'resp' and 'body' in a list[].
Then I change my code to this:
request.post options, (err,resp,body)->
if err
console.log err
console.log "body--------->",body
It works well too.
But I remember I have used .spread and get the right result.

$ npm list bluebird
[email protected]
$ npm list request
[email protected]

I turn to [email protected], the .spread works well.
Did I miss somthing?

Most helpful comment

{multiArgs: true} as the second parameter to promisifyAll or not using .spread and using then.

Bluebird does not promisify with arrays by default anymore - it does with the first parameter.

All 2 comments

{multiArgs: true} as the second parameter to promisifyAll or not using .spread and using then.

Bluebird does not promisify with arrays by default anymore - it does with the first parameter.

@benjamingr Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonemazzoni picture simonemazzoni  路  4Comments

popod picture popod  路  4Comments

SimonSchick picture SimonSchick  路  6Comments

icodeforlove picture icodeforlove  路  3Comments

overlookmotel picture overlookmotel  路  5Comments