Skip to content
Snippets Groups Projects
Verified Commit 8a1162e6 authored by Erick Hitter's avatar Erick Hitter
Browse files

Don't die if no location data is provided

parent 558c6278
No related branches found
No related tags found
No related merge requests found
......@@ -27,10 +27,16 @@ app.get('/', function(req, res){
//app.post is triggered when a POST request is sent to the URL ‘/post’
app.post('/post', function(req, res){
// Can't proceed without an API key
if ( ! apikey.length ) {
return res.sendStatus( 500 );
}
// Don't bother if there's nothing to look up
if ( 'undefined' === typeof req.body.text || ! req.body.text.length ) {
return res.sendStatus( 400 );
}
var parsed_url = url.format({
pathname: 'http://api.wunderground.com/api/' + apikey + '/conditions/q/' + req.body.text + format,
});
......@@ -63,5 +69,5 @@ app.post('/post', function(req, res){
//tells Node which port to listen on
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
console.log('Weather on the Slash is running on port', app.get('port'));
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment