Skip to content

Instantly share code, notes, and snippets.

@sharpred
Created June 7, 2017 10:15
Show Gist options
  • Save sharpred/6215e1867dc278a62530f610e8067116 to your computer and use it in GitHub Desktop.
Save sharpred/6215e1867dc278a62530f610e8067116 to your computer and use it in GitHub Desktop.
webtask for dark skies api
'use latest'
module.exports = function (context, cb) {
var request = require("request");
//37.8267
//-122.4233
var url = `https://api.darksky.net/forecast/${context.data.dsApiKey}/${context.data.latitude},${context.data.longitude}?exclude=%5Bminutely,daily,%20%20flags%5D?units=%5Buk2%5D`;
var options = {
method: 'GET',
url: url
};
request(options, function (error, httpResponse, body) {
if (error) {
console.error(error);
cb("beh", null);
}
var obj = JSON.parse(body);
cb(null, body);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment