Skip to content

Instantly share code, notes, and snippets.

@mdobson
Last active August 29, 2015 13:56
Show Gist options
  • Save mdobson/9254231 to your computer and use it in GitHub Desktop.
Save mdobson/9254231 to your computer and use it in GitHub Desktop.
Argo sample.
argo()
.post('/loc', function(handle){
handle('request', function(env, next){
env.request.getBody(function(err, body) {
if(err) {
//blah
} else {
//Get usergrid object
//This would be something from the SDK.
var usergridObject = getUgObj();
//Use whatevs data from the post body.
var b = JSON.parse(body.toString());
request('http://maps.googleapis.com/maps/api/geocode/json?address=' + b.place + '&sensor=true', function(err, result, foo) {
usergridObject.set('location') = {
'latitude': JSON.parse(foo).results[0].geometry.location.lat,
'longitude': JSON.parse(foo).results[0].geometry.location.lng
};
usergridObject.save(function(err, res){
if(err) {
//err handle
} else {
next(env);
}
});
});
}
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment