How to fetch remote website content into a variable


#1

Currently writing a notification feed for Nagios notifications.
It’s something like hckrnews only for Nagios notifications.

The challenge is that meteor needs to authenticate against a htaccess file and then save the content into a variable where I can continue to manipulate the data.

Now I’ll mix up a bit of Meteor- with Pseudo code to explain what I intend to do.

if (Meteor.isServer) {
  Meteor.startup(function () {
    var html = getFile("http://www.site.com/file.html", USERNAME, PASSWORD);
  });
}

#2

Found the solution.

First add http to your meteor app:

meteor add http

Add the code to fetch the data and save that data in resultSet.

if (Meteor.isServer) {
  Meteor.startup(function() {
    var resultSet = HTTP.get("https://monitor.company.com/cgi-bin/nagios3/notifications.cgi?contact=all", {
      auth: 'username:password'
    });
  });
}