I'm trying to use highland in combination with the heroku-client. But internally in the heroku client it uses this
, even if I try to bind
to bind this, the function gives and error message where there is a refrance to this
I'm not able to get it to work.
Right no the code looks like this
const Heroku = require('heroku-client');
const hl = require('highland');
var hk = new Heroku({
token: process.env.HEROKU_API_TOKEN
});
var list = hl.wrapCallback(hk.apps().list.bind(hk));
list().toArray((a) => 'console.log(a)')
So this code snippet fails with the following error message:
...node_modules/heroku-client/lib/resourceBuilder.js:35
if (this.params.length !== pathParams.length) {
^
TypeError: Cannot read property 'length' of undefined
Yo! :-)
You're binding to hk
and not what hk.apps()
return, which is what the list
function depends on (it's a member of what hk.apps()
returns)
Try this:
const Heroku = require('heroku-client');
const hl = require('highland');
const hk = new Heroku({
token: process.env.HEROKU_API_TOKEN
});
const hkApps = hk.apps();
const list = hl.wrapCallback(hkApps.list.bind(hkApps));
list().toArray((a) => 'console.log(a)')