From c73e4f803cc94a461bcb2ba8e7571eb31a143d31 Mon Sep 17 00:00:00 2001 From: JayWll Date: Mon, 13 Apr 2020 14:37:50 -0600 Subject: [PATCH] Update to original weather app to use weatherstack instead of darksky --- weather-app/utils/forecast.js | 4 ++-- web-server/src/utils/geocode.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/weather-app/utils/forecast.js b/weather-app/utils/forecast.js index f6fe52d..cafd7bb 100644 --- a/weather-app/utils/forecast.js +++ b/weather-app/utils/forecast.js @@ -1,7 +1,7 @@ const request = require('request') const forecast = (latitude, longitude, callback) => { - const url = 'https://api.darksky.net/forecast/0466bccb953c0b9daeb091a529da2c0d/' + latitude + ',' + longitude + '?units=si' + const url = 'http://api.weatherstack.com/current?access_key=360ee65db0f798aa09021f493b5b02c9&query=' + latitude + ',' + longitude + '&units=m' request({ url, json: true }, (error, {body}) => { if (error) { @@ -9,7 +9,7 @@ const forecast = (latitude, longitude, callback) => { } else if (body.error) { callback('Unable to find location', undefined) } else { - callback(undefined, body.daily.data[0].summary + ' It is currently ' + body.currently.temperature + ' degrees out. There is a ' + body.currently.precipProbability + '% chance of rain.') + callback(undefined, body.current.weather_descriptions[0] + '. It is currently ' + body.current.temperature + ' degress out. It feels like ' + body.current.feelslike + ' degress.') } }) } diff --git a/web-server/src/utils/geocode.js b/web-server/src/utils/geocode.js index fbbd4d0..31852ef 100644 --- a/web-server/src/utils/geocode.js +++ b/web-server/src/utils/geocode.js @@ -4,6 +4,7 @@ const geocode = (address, callback) => { const url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + encodeURIComponent(address) + '.json?access_token=pk.eyJ1IjoiamFzb24zMmRldiIsImEiOiJjazFsNHd5djcwMXptM2htbW8zM3MyZGxuIn0.-TtNNGFysQPQRfGR1P8DUA&limit=1' request({ url, json: true }, (error, {body}) => { + console.log(body) if (error) { callback('Unable to connect to location services!', undefined) } else if (body.features.length === 0) {