json - Meteor.http.call (call URL API) -
so i'm trying make call bible verse api in meteor application. made template name="display"
, simple {{checkitout}}
in template.
then template, tried make call in corresponding helper. looks (in coffeescript, javascript readers should understand well):
@template.display.helpers checkitout:-> result = meteor.http.call("get","http://labs.bible.org/api/passage=john%203:2&type=json") console.log(result)
the url json of bible verse, problem is, meteor.http.call
requires third argument, "callback" (because in client folder). read documentation + examples , have no idea means.
also, if call this, result json file, or need fit within new hash? , callback mean? can give me example?
as helpers synchronous , api calls not, need store call result in reactive variable , return helper:
verse = "loading..." verseloaded = false versedep = new deps.dependency() template.display.checkitout = -> versedep.depend() unless verseloaded verseloaded = true meteor.http.get "...", (error, result) -> verse = "..." versedep.changed() verse
Comments
Post a Comment