Skip to content

Commit

Permalink
Use result from map instead of push to array
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Feb 19, 2021
1 parent 2be9f34 commit b2353a4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ app.get('/weather', (request, response) => {
key:apiKey, city:searchedCity, days:8
};

const weatherArr = [];
superagent.get(url).query(searchParameters).then(returnData => {
returnData.body.data.map( day => {
weatherArr.push(new Weather(day.weather.description,day.valid_date));
})
let weatherArr = returnData.body.data.map( day => {
return new Weather(day.weather.description,day.valid_date);
});
response.status(200).send(weatherArr);
}).catch(error => {
response.status(500).send('There was an error');
Expand Down

0 comments on commit b2353a4

Please sign in to comment.