node-trello
node-trello copied to clipboard
Add Promise compatibility
- Update dependency
should - Return a promise for then chaining
Any consideration to upgrade node version in travis? 0.10 is kind of legacy. If not, I'll try to add Promise polyfill.
0.10 is kind of legacy.
Understatement of the year! 😄 Definitely, just merged #49, but feel free to upgrade support further if you need to.
Can you also include an update to the README? Thanks!
I've updated the README!
If I'm not mistaken, it doesn't exactly work as shown in the README.
It says this is valid
// Use it as a promise
t.get("/1/members/me", { cards: "open" })
.then(function(data) { console.log(data); });
However, the params don't seem to be taken into account.
On the other hand, this works as intended
t.get("/1/members/me", { cards: "open" }, (err, data) => console.log(err, data))
My guess is, the problem comes from those lines https://github.com/awesomejerry/node-trello/blob/master/lib/node-trello.js#L50-L53.
if (arguments.length === 3) {
callback = argsOrCallback;
args = {};
}
You're checking if the function receives 3 arguments, the third argument is considered the callback. This is incorrect in the first case: it calls the function with the arguments
("GET", "/1/members/me", { cards: "open" })
I suppose changing it to
arguments.length === 4
should work as intended.
EDIT: On second thought, this might not work either if the function is called with
t.get("/1/members/me", (err, data) => console.log(err, data))
Because it will indeed produce the 3 arguments
("GET", "/1/members/me", (err, data) => console.log(err, data))
EDIT2: maybe this would work https://github.com/dfdeagle47/node-trello/blob/master/lib/node-trello.js#L53-L60
Cheers