【发布时间】:2016-12-01 21:50:15
【问题描述】:
我从流星方法调用 API。如何将数据返回给客户端?我没有成功,如下所示:
Meteor.methods({
'geCoordinates': function(distance,location) {
this.unblock();
geocoder.geocode(location, function ( err, data ) {
if (err) {
console.log("See on error " + err)
} else {
lat = data.results[0].geometry.location.lat
lng = data.results[0].geometry.location.lng
}
url = 'http://localhost:3005/events?lat='+lat+'&lng='+lng+'&distance='+distance+'&sort=venue&accessToken=1048427405248222|u4dBjiRw-9gdsgml1puWYFGrEvw'
})
return url
}
})
【问题讨论】:
-
你试过
Meteor.wrapAsync吗?这里有很好的解释 - themeteorchef.com/snippets/synchronous-methods/…
标签: javascript meteor