diff --git a/README.md b/README.md index 0ff9ba8..9ef2e9f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ An example of how to get the weather based on location. ```javascript var weather = require('weather'); -weather({location: 'Melbourne'}, function(data) { +weather({location: 'Melbourne', appid: 'your-yahoo-app-id'}, function(data) { if (data.temp > 30) { console.log("Damn it's hot!"); } @@ -14,10 +14,56 @@ weather({location: 'Melbourne'}, function(data) { Example JSON result: ```javascript -{ - temp: 18, // Current temperature - high: 20, // High for the day - low: 9, // Low for the day +{ + date: 'Tue, 15 Oct 2013 4:50 pm BST', + text: 'Partly Cloudy', + code: '30', + temp: '13', // Current temperature + high: '12', // High for the day + low: '8', // Low for the day + forecast: + [ + { + day: 'Tue', + date: '15 Oct 2013', + low: '8', + high: '12', + text: 'Cloudy', + code: '26' + }, + { + day: 'Wed', + date: '16 Oct 2013', + low: '12', + high: '14', + text: 'PM Rain', + code: '12' + }, + { + day: 'Thu', + date: '17 Oct 2013', + low: '12', + high: '18', + text: 'Mostly Sunny', + code: '34' + }, + { + day: 'Fri', + date: '18 Oct 2013', + low: '13', + high: '16', + text: 'Few Showers', + code: '11' + }, + { + day: 'Sat', + date: '19 Oct 2013', + low: '13', + high: '18', + text: 'Showers', + code: '11' + } + ] } ``` diff --git a/yahoo.js b/yahoo.js index 8034729..98117db 100644 --- a/yahoo.js +++ b/yahoo.js @@ -52,6 +52,13 @@ yahoo.weather = function(woeid, callback) { var description = result.channel.item['description']; weather.high = high.exec(description)[1]; weather.low = low.exec(description)[1]; + + weather.forecast = []; + + result.channel.item['yweather:forecast'].forEach(function (item) { + weather.forecast.push(item['@']); + }); + } catch(e) { onError('Failed to find weather'); return;