Weather.getCurrentForecast()

Get the current weather at a specific latitude and longitude.

This is purely a convenience function, you could just pass the current time/date into the get-forecast function.

Usage

Hover over inputs/exits for more info.

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


// Get the current weather at a specific latitude and longitude.

Weather.getCurrentForecast({

lat: '42.3507282',

lng: '-71.13212709999999',

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'
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.

'{}'