New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

darksky-bluebird

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

darksky-bluebird

Lightweight wrapper for Dark Sky weather API that returns Bluebird promises.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

darksky-bluebird

js-semistandard-style

Wrapper for the Dark Sky API

Only dependency is Bluebird!

Here's how to use it:

Require the module:

var Forecast = require('darksky-bluebird');

Instantiate an instance of the wrapper. You'll need to specify your API key. You may also supply your own timeout value, which defaults to 2000ms or 2 seconds if not provided.

var forecast = new Forecast({
  key: process.env.DARK_SKY_API_KEY,
  timeout: 2500
});

To fetch a forecast for the current time:

forecast.fetch(latitude, longitude)
  .then(function (result) {
    console.dir(result);
  })
  .catch(function (error) {
    console.error(error);
  });

To fetch a forecast for a specific time:

var time = new Date().setDate(32);

forecast.fetch(latitude, longitude, time)
  .then(function (result) {
    console.dir(result);
  })
  .catch(function (error) {
    console.error(error);
  });

To fetch a forecast for the current time with any of the "options" specified on the documentation page:

var options = {
  extend: 'hourly',
  units: 'auto'
};

forecast.fetch(latitude, longitude, options)
  .then(function (result) {
    console.dir(result);
  })
  .catch(function (error) {
    console.error(error);
  });

To fetch a forecast for a specific time with additional "options" from the documentation page:

var time = new Date().setDate(32);
var options = {
  units: 'si',
  exclude: 'hourly,minitely',
  lang: 'x-pig-latin'
};

forecast.fetch(latitude, longitude, time, options)
  .then(function (result) {
    console.dir(result);
  })
  .catch(function (error) {
    console.error(error);
  });

That's it folks! Now go build something awesome!

Keywords

FAQs

Package last updated on 09 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc