react-cached-forecast
v0.8.10
Published
Weather forecast app based on React and with server caching to minimize forecast API calls
Downloads
12
Maintainers
Readme
React weather forecast with caching
Weather forecast app based on React and with server caching to minimize forecast API calls.
The app takes arguments like latitude, longitude, language, units, and other parameters from the ForecastIO API and returns a HTML string with the weather forecast for the region like:
Demo here
Usage example
Server side code:
let API = require('react-cached-forecast');
let forecastKey = require('../config/keys'); // or where you have the keys
let forecast = new API(forecastKey, {units: 'si'});
app.get('/', function(req, res){
const lat = req.query.lat;
const lng = req.query.lng;
const options = {lang: 'sv'};
forecast.get(lat, lng, options).then(html => {
res.send(html);
});
});
In the client I'm using Skycons for the animations. Check the demo or open a issue if you have questions.
App defaults
Units default to si
(european), check the Forecast docs for other units.
Language defaults to en
.
Place name defaults to Timezone region. Otherwise set placeName
in the options.