So what I am trying to do is make an HTTP get request and then update a view with the response. For some reason it's not working. Here is what I have.
I have been following this gist: https://gist.github.com/3443021
On the client:
Template.search.items = function() {
var query = Session.get("query");
console.log(query);
var resp;
Meteor.call("search", query, function(err, res) {
console.log(res);
//return res;
return [1,2,4];
});
};
On the server:
Meteor.methods({
search: function(query) {
var fut = new Future();
// var onComplete = fut.resolver();
Meteor.http.get("http://localhost:4242/autocomplete/"+query, function(err, res) {
var content = res.content;
var resp = JSON.parse(content);
console.log(resp);
fut.ret(resp)
});
return fut.wait();
}
});
And on the view I am doing:
<template name="search">
<h1>test</h1>
<table class="table table-hover">
<tbody>
{{#each items}}
{{> searchItem}}
{{/each}}
</tbody>
It seems if I return from inside the Meteor.call function nothing gets sent to the view. Any ideas?