Question

I want to use Google Feed API from a server (Node.js). I have already installed the googleapis module. My code is:

// parts omitted
var googleapis = require('googleapis');
// parts omitted
googleapis.discover('feeds').execute(function(err, client) {
var feed = new google.feeds.Feed('http://rss.lemonde.fr/c/205/f/3050/index.rss');
});
// parts omitted

But Node.js console tells me that "google is not defined". Any idea of the problem and solution?

Was it helpful?

Solution

to access Google Feed API using Node.js, you should try the google-feed-api module as explained here:

https://www.npmjs.org/package/google-feed-api

Hope it helps!

Edit:

I tried this with your URL and worked fine:

var gfeed = require('google-feed-api');
var feed = new gfeed.Feed('http://rss.lemonde.fr/c/205/f/3050/index.rss');
feed.listItems(function(items){
    console.log(items);
});

OTHER TIPS

It's because google is literally not defined. I don't know very much about that module, but I think that instead of using the google var you should use client , because that's what the execute function returns.
So the code would be:

// parts omitted
var googleapis = require('googleapis');
// parts omitted
googleapis.discover('feeds').execute(function(err, client) {
var feed = new client.feeds.Feed('http://rss.lemonde.fr/c/205/f/3050/index.rss');
});
// parts omitted
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top