euforic / banking.js

The Missing API for Banks - Get all of your transactions and balances using node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Promises

mrmarcsmith opened this issue · comments

Hello,
I would like to use promises like this:

return bank.getStatement({start:20170101, end:20180201}).then(function(response){
    //Do Something
},function(error){
    //Handle Error
});

but when I do that it only returns the XML with no parsed body. If I'm doing something wrong please correct me, otherwise what would it look like to add this feature?

You can just wrap it if you would like to use promises

new Promise((resolve, reject) => {
  bank.getStatement({start:20170101, end:20180201}, (err, res) => {
    if (err) {
      reject(err)
      return    
    }
    resolve(res)
  })
})

You can use util.promisify() in node.js if you are using 8.x or later.