I am trying to convert the froogaloop javascript api into a promisified API calls,
here is my code
FroogaLoopPlayer.promisify = (player) => {
//player.on = player.addEvent;
_.each(functionNames, (fn) => {
_.each(fn, (value, key) => {
player[key] = () => {
var data;
return new Bluebird(resolve => {
player.api(value, (d) => {
console.log(d);
data = d;
console.log(data);
});
resolve(data);
});
};
});
});
return player;
};
the problem is, the data i get is always undefined. What I could be doing wrong?. I have already tried this, which i suppose is the correct way.
return new Bluebird(resolve => {
player.api(value, resolve);
});