January 2018
Beginner
658 pages
13h 10m
English
Let's go ahead and define all the arguments that are getting passed in. We add lat, lng, and our callback:
var getWeather = (lat, lng, callback) => {
First off let's inject that latitude. We'll take the static latitude, remove it, and between the forward slash and the comma we'll inject it using dollar with our curly braces. This lets us inject a value into our template string; in this case lat. And we can do the exact same thing right after the comma with the longitude. We'll remove the static longitude, use the dollar sign with our curly braces to inject the variable into the string:
var getWeather = (lat, lng, callback) => { request({ url: `https://api.forecast.io/forecast/4a04d1c42fd9d32c97a2c291a32d5e2d/${lat},${lng}`, ...Read now
Unlock full access