I have a registered helper that makes call to the server method. The server method calls API and returns the api-response to the helper.
UI.registerHelper('userList', function () {
//Call to the server method
Meteor.call('userAccountsApi', cid, extUserId, loginType, function (error, result) {
if (error) {
console.log("error occured on receiving data on server. ", error);
return null;
}
return result;
});
This is the server side method:
userApi: function (params) {
var url = "URL created using the parameters";
var result,listOfAccounts;
try {
//API call
result = HTTP.get(url);
} catch (error) {
// We got an error
}
if (result.statusCode == 200) {
var respJson = JSON.parse(result.content);
return respJson;
}
//logic to return the error message
return error;
}
I want registered helper to call the server method synchronously and complete execution only when it gets the data from the server method.