Monday, 15 June 2015

meteor - Make a http get request to rest api and convert to a collection -



meteor - Make a http get request to rest api and convert to a collection -

is possible create meteor.http.get("localhost:4000/api/resource.json") , utilize returned response meteor.collection?

sure. let's json looks like:

{ 'results': [ { 'name': 'bob', 'eyes': 'brown' }, { 'name': 'sue', 'eyes': 'blue' } ] }

to insert collection do:

meteor.http.get("localhost:4000/api/resource.json", function(error, result) { if (result.statuscode === 200) { (var = 0; < result.data.results.length; i++) { mycollection.insert(result.data.results[i]) } } else { console.log(result); } }

meteor

No comments:

Post a Comment