Meteor.http.call
is an asynchronous function with a callback. A quick way I can think to do what you want is the following:
const items = [];
Meteor.http.call("GET", url,function(error,result){
$.each(JSON.parse(result.content), function(key, value){
items.push(value)
});
handleItems(items);
});
function handleItems(items) {
console.log(items.length) // 1
// Do what you want with the items array here.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.