I am trying to follow this thread here: How can one parse HTML server-side with Meteor?
Unfortunately I get the following errors when doing so:
Uncaught Error: Can't make a blocking HTTP call from the client; callback required.
Here is the javascript code for my project:
var cheerio;
if (Meteor.isClient) {
Template.entry.events = {
'click .btn_scrape' : function() {
$ = cheerio.load(Meteor.http.get("https://github.com/meteor/meteor").content);
console.log($('.commit-title').text().trim());
},
}
}
if (Meteor.isServer) {
Meteor.startup(function () {
var require = __meteor_bootstrap__.require;
cheerio = __meteor_bootstrap__.require('cheerio');
});
}
if I put the code in Meteor.startup(function()... nothing happens, there is no error and nothing is logged to the console.
I'd like to be able to call a function when a button is clicked to get the content in a textbox and scrape it, but this I can do later once I get the code working.
Would anyone by chance know how to fix this?
Thank you for your time,
Jonathan.