Last active
August 29, 2015 13:56
-
-
Save mdobson/9254231 to your computer and use it in GitHub Desktop.
Argo sample.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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