Video 69: Avoiding Global Modules
Completed weather app, including all updates from Section 9 (Videos 60-69)
This commit is contained in:
@@ -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 = 'https://api.darksky.net/forecast/bae9e39ba5c00299d5a95b35c1ae20cc/' + latitude + ',' + longitude + '?units=si'
|
||||
|
||||
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.daily.data[0].summary + ' It is currently ' + body.currently.temperature + ' degrees out. Today\'s high will be ' + body.daily.data[0].temperatureMax + ' degrees, with a low of ' + body.daily.data[0].temperatureMin + '. There is a ' + body.currently.precipProbability + '% chance of rain.')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const request = require('request')
|
||||
|
||||
const geocode = (address, callback) => {
|
||||
const url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + encodeURIComponent(address) + '.json?access_token=pk.eyJ1IjoiamF5d2xsIiwiYSI6ImYyZjkyMGNlOTgyNGQ5ZWM5ZDExN2FjNGYwMDZmNTQ4In0.y3lv5ddmGhVNSL7wfMpB0g&limit=1'
|
||||
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}) => {
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user