NWS-Current-Temperature is a library that provides functionality to obtain the current temperature in a location using zip code, city name, or address within the United States. It uses the Google Geocoding Service, as well as the NWS Forecast Pages. You will need to configure a Google API key for your application to use the library.
Use npm to install the nws-current-temperature library:
npm install nws-current-temperature --save
Use the Google API Console to create an API key for your application and update the value of the geocodingApiKey
field in the config.json
file located in node_modules/nws-current-temperature
. Additionally, set the nwsUserAgent
to the name of your application. Finally, the temperatureDecimalPrecision
can be changed to adjust the precision of the temperature that is returned from the library.
nws-current-temperature can be included as a reference in your Node.js application.
const nwsCurrentTemperature = require('nws-current-temperature');
const location = 'Austin, TX';
nwsCurrentTemperature.getTemperatureFor(location, temperature => {
console.log(location + ': ' + temperature + '°F');
});
MIT © Jennifer Rogers