Skip to content

Instantly share code, notes, and snippets.

@VerizonMediaOwner
Last active May 12, 2019 12:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VerizonMediaOwner/40e8edccaab25e2b3b5001d2ecc1d070 to your computer and use it in GitHub Desktop.
Save VerizonMediaOwner/40e8edccaab25e2b3b5001d2ecc1d070 to your computer and use it in GitHub Desktop.
Yahoo Weather API JavaScript Example
// Require node-oauth package: npm install oauth
// Copyright 2019 Oath Inc. Licensed under the terms of the zLib license see https://opensource.org/licenses/Zlib for terms.
var OAuth = require('oauth');
var header = {
"X-Yahoo-App-Id": "your-app-id"
};
var request = new OAuth.OAuth(
null,
null,
'your-consumer-key',
'your-consumer-secret',
'1.0',
null,
'HMAC-SHA1',
null,
header
);
request.get(
'https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json',
null,
null,
function (err, data, result) {
if (err) {
console.log(err);
} else {
console.log(data)
}
}
);
@srujanponnur
Copy link

hello, how to access the data outside the scope of request.get, I am having trouble with that

@chethanwe96
Copy link

call the function outside request.get
create a global variable to parse the json data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment