Hi,
I have this Meteor.http call to google api on one event:
var url = “https://maps.googleapis.com/maps/api/geocode/json?address=” + street + " " + city+ “&key=AIzaSyCBpwwwwwwwwwwwwwww”;
Meteor.http.get(url, {}, function (err, results) {
//a Meteor.call
})
It works for it self. but when I try to insert into it, a Meteor call, which also works fine for it self, out side that callback:
Meteor.call(‘setLocation’, this._id, this.createdBy, location, function(error, result){
if(error){
console.log(error);
}else{
}
});
I get this match error:
errorClass {message: “Match error: Expected string, got undefined”, path: “”
It’s exactly the same call and method that runs well outside the callback.
So what’s the right way to handle this? how to do a Meteor call from with in a google api call back?
Thanks,
Avi.
this._id and this.createdBy are not scoped to the enclosing context and will be undefined. Also, location may or may not be defined (it depends what’s happening before this call).
I have no visibility of where location is set, so I don’t know whether it will be defined or not. If you share more of the surrounding code, including where that variable comes from that may help.
Also, please surround your code blocks with triple backticks: