fzxu / tumblrwks

One node.js package lib talks to tumblr API v2 that really works.
MIT License
33 stars 11 forks source link

Promise is not defined error #15

Open micheledallatorre opened 7 years ago

micheledallatorre commented 7 years ago

When trying to run

var Tumblr = require('tumblrwks');

/*
  You can get the consumerKey and consumerSecret by registing a tumblr app: http://www.tumblr.com/oauth/apps
*/

var tumblr = new Tumblr(
  {
    consumerKey: 'your consumer key'
  }//, "arktest.tumblr.com"
  // specify the blog url now or the time you want to use
);

tumblr.get('/info', {hostname: 'arktest.tumblr.com'}, function(err, json){
  console.log(json);
});

// Or with Promises
tumblr.get('/info', {hostname: 'arktest.tumblr.com'}).
    then(function (json) {
        console.log(json);
    }, function (error) {
        console.log(error)
    });
});

I get in the log the "Promise is not defined" error.

Thanks.

micheledallatorre commented 7 years ago

UPDATE: following http://stackoverflow.com/questions/35639924/why-would-i-get-a-promise-is-not-defined-error-on-node-v5-7-0 I modified https://github.com/arkxu/tumblrwks/blob/master/lib/tumblrwks.js adding at the top the following line

// fix error in log when using tumblrwks: Promise is not defined
var Promise = require('es6-promise').Promise;

and then running npm install -S es6-promise

The error is not happening anymore.