Thursday, 29 August 2013

Tumblr.js API -- require() fails

Tumblr.js API -- require() fails

I've been trying to get tumblr.js api to work for about 3 days now on
localhost and hosted. My app and keys are valid since I was able to access
it with php. This is the readme.md example provided from
https://github.com/tumblr/tumblr.js with changes provided by reviewing
https://groups.google.com/forum/#!topicsearchin/tumblr-api/tumblr.js/tumblr-api/gz8Zv-Mhex4.
var tumblr = require('index.js');
var client = tumblr.createClient({
consumer_key: '<consumer key>',
consumer_secret: '<consumer secret>',
token: '<oauth token>',
token_secret: '<oauth token secret>'
});
// Show user's blog names
client.userInfo(function (err, data) {
data.blogs.forEach(function (blog) {
console.log(blog.name);
});
});
Using firebug, I find that require is not defined selecting
require('index.js') as the issue. index.js holds:
var tumblr = require('lib/tumblr');
tumblr.request(require('request'));
module.exports = tumblr;
Upon complete failure I've search online and reviewed countless articles,
blogs and posts to no avail. Where am I messing up at? I want to use the
api with minimal or no work-around.

No comments:

Post a Comment