Weather.getForecast()

Retrieves the forecast of a specific latitude and longitude at a specific time

Usage

Hover over inputs/exits for more info.

var Weather = require('machinepack-forecast.io');


// Retrieves the forecast of a specific latitude and longitude at a specific time

Weather.getForecast({

lat: '42.3507282',

lng: '-71.13212709999999',

time: '2013-05-06T12:00:00-0400',

timeFormat: 'YYYY-MM-DD',

apiKey: 'ab1d526c3c074c2a48c25476c19a9d0a',

options: { units: 'si', exclude: [ 'currently', 'minutely', 'hourly', 'daily', 'alerts', 'flags' ], extend: 'hourly', lang: 'es' },

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// You have passed in an invalid latitude or longitude.

invalidLatOrLong: function () {

 

},

// Your Forecast.io API key is not valid.

invalidAPIKey: function () {

 

},

// You passed an invalid options object

invalidOptions: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

lat required

The latitude of the location you are trying to forecast.

'42.3507282'
lng required

The longitude of the location you are trying to forecast.

'-71.13212709999999'
time required

Any valid Moment.js time (http://momentjs.com)

'2013-05-06T12:00:00-0400'
timeFormat required

Any valid Moment.js time format (http://momentjs.com)

'YYYY-MM-DD'
apiKey required

This is your Forecast.io API Key.

'ab1d526c3c074c2a48c25476c19a9d0a'
options

An object with keys representing the query parameters accepted by the forecast.io API. (https://developer.forecast.io/docs/v2#options)

{
  units: 'si',
  exclude: [ 'currently', 'minutely', 'hourly', 'daily', 'alerts', 'flags' ],
  extend: 'hourly',
  lang: 'es'
}

Exits

error

An unexpected error occurred.

invalidLatOrLong

You have passed in an invalid latitude or longitude.

invalidAPIKey

Your Forecast.io API key is not valid.

invalidOptions

You passed an invalid options object

success

OK.

'{}'