Ok, I’m stuck. I feel like I’ve checked everything three times over here, and I just can’t see what I’m doing wrong.
I have the following code in helpers:
Template.hostList.helpers({
    hostURL: function() {
        return URLToCheck.find({});
    },
    getStatus: function() {
        try {
            let url = this.url;
            let myHostStatus = HostStatus.findOne({ "url": url }, { sort: { "runOn": -1 }});
            let runOnDate = myHostStatus.runOn;
            if (runOnDate != "") {
                let momentOnDate = moment(runOnDate).format("MM/DD/YYYY hh:mm:ss");
                Session.set("lastRunOn", momentOnDate);
            } else {
                return "Not Run Yet.";
            }
            return myHostStatus;
        } catch (error) {
            console.log("Error in getStatus call: " + error);
        }
    },
    runOnDate: function() {
        return Session.get("lastRunOn");
    }
});
I have the following information in my two collections:
Collection URLToCheck
{
        "_id" : "aqdjNRTQHHhuouZiL",
        "url" : "https://trivia-challenge.org",
        "freqCheck" : 5,
        "emailIfDown" : false,
        "emailAddress" : ""
}
and Collection HostStatus
{
        "_id" : "QGaqW3iPf8wrGsxFJ",
        "url" : "https://trivia-challenge.org",
        "status" : "Up",
        "statusColor" : "#32CD32",
        "runOn" : ISODate("2018-05-14T00:29:47.610Z")
}
I keep getting (on the client side in the console) the error:
TypeError: Cannot read property "runOn" of undefined.
and it’s at the line above
let runOnDate = myHostStatus.runOn;
I’m getting back the collection info in my query because the other values are showing up in the UI. There’s obviously a runOn value in the collection, but I can’t figure out why I keep getting this error in the console.
Any help is greatly appreciated on this.