Utilizing my meteor application, I fetch and display data from Parse.com. Initially, I integrated the parse.com javascript query directly into the template's rendered function, which was successful.
Now, I aim to utilize the Parse.com query in a helper function to pass it to a meteor {{#each}} loop within my template.
Template.dashboard.helpers({
app: function () {
//initialize new array
var appsArr = [];
//Create a Parse Query for Post objects
var query = new Parse.Query("Apps");
query.descending("createdAt");
var appsObj = {};
query.find({
success: function(results) {
// Add the returned Parse.Object values to appsArr
for (var i = 0; i < results.length; i++) {
appsObj = {};
appsObj.obid = results[i].id;
appsObj.title = results[i].attributes.title;
appsObj.screenshot1 = results[i].attributes.screenshot1._url;
appsObj.appIcon = results[i].attributes.appIcon._url;
appsArr.push(appsObj);
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
return appsArr
}
});
Whenever I attempt to return my array (appsArr) in the helper function, I encounter the error: "Exception in template helper: undefined". Furthermore, I am unable to view my parse objects in the console. Nonetheless, the same code functions correctly in the rendered function.
Being relatively new to Meteor.js and Blaze templates, I seek assistance in properly implementing this parse query within the helper function so that I can use {{#each}} in the template.
{{#each app}}
<h3 class="app-title">{{title}}</h3>
{{/each}}
Your help is greatly appreciated!