Add CORS to weather endpoint

This commit is contained in:
Samer Albahra
2019-03-01 00:25:46 -06:00
parent b0a4da885b
commit aa5b6fb9ba
4 changed files with 32 additions and 7 deletions

View File

@@ -76,6 +76,9 @@ function getOWMWeatherData( location, callback ) {
weather.wind = weather.wind / maxCount;
weather.precip = weather.precip / maxCount;
weather.icon = data.list[0].weather[0].icon;
weather.region = data.city.country;
weather.city = data.city.name;
weather.description = data.list[0].weather[0].description;
location = location.join( "," );
@@ -196,7 +199,10 @@ exports.showWeatherData = function( req, res ) {
location = [ parseFloat( location[ 0 ] ), parseFloat( location[ 1 ] ) ];
// Continue with the weather request
getOWMWeatherData( location, function( data ) { res.json( data ); } );
getOWMWeatherData( location, function( data ) {
data.location = location;
res.json( data );
} );
} else {
// Attempt to resolve provided location to GPS coordinates when it does not match
@@ -208,7 +214,10 @@ exports.showWeatherData = function( req, res ) {
}
location = result;
getOWMWeatherData( location, function( data ) { res.json( data ); } );
getOWMWeatherData( location, function( data ) {
data.location = location;
res.json( data );
} );
} );
}
};