Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
Expand All @@ -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'
}
]
}
```

Expand Down
7 changes: 7 additions & 0 deletions yahoo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down