From 15091b2630a12367c4b26eaf31a13ed6cb49b7f7 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sun, 25 Aug 2019 13:57:08 -0600 Subject: [PATCH] Video 33 --- weather-app/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/weather-app/app.js b/weather-app/app.js index 27240fb..a22a7cd 100644 --- a/weather-app/app.js +++ b/weather-app/app.js @@ -1,3 +1,6 @@ +// Mapbox token: +// pk.eyJ1IjoiamF5d2xsIiwiYSI6ImYyZjkyMGNlOTgyNGQ5ZWM5ZDExN2FjNGYwMDZmNTQ4In0.y3lv5ddmGhVNSL7wfMpB0g + const request = require('request') const url = 'https://api.darksky.net/forecast/0466bccb953c0b9daeb091a529da2c0d/37.8267,-122.4233?units=si' @@ -5,3 +8,11 @@ const url = 'https://api.darksky.net/forecast/0466bccb953c0b9daeb091a529da2c0d/3 request({ url: url, json: true }, (error, response) => { console.log(response.body.daily.data[0].summary + ' It is currently ' + response.body.currently.temperature + ' degrees out. There is a ' + response.body.currently.precipProbability + '% chance of rain.') }) + +const geocodeURL = 'https://api.mapbox.com/geocoding/v5/mapbox.places/Los%20Angeles.json?access_token=pk.eyJ1IjoiamF5d2xsIiwiYSI6ImYyZjkyMGNlOTgyNGQ5ZWM5ZDExN2FjNGYwMDZmNTQ4In0.y3lv5ddmGhVNSL7wfMpB0g&limit=1' + +request({ url: geocodeURL, json: true }, (error, response) => { + const latitude = response.body.features[0].center[1] + const longitude = response.body.features[0].center[0] + console.log(latitude, longitude) +})