zenware / iso-openweathermap

Isomorphic Access to OpenWeatherMap API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iso-openweathermap NPM version Build Status Dependency Status Coverage percentage

Isomorphic OpenWeatherMap API

Installation

$ npm install --save iso-openweathermap

Usage

var OpenWeatherMap = require('iso-openweathermap');

$(document).ready(() => {

  const config = {
    API_ENDPOINT: 'http://api.openweathermap.org/data/2.5/weather', 
    API_KEY: 'Your API Key',
    UNITS: 'imperial', 
    MODE: 'json', 
    LAT: null, 
    LON: null,
    ACCURACY: 'high', 
    CALLBACK: null, 
    LANGUAGE: 'en',
  };

  let weather = new OpenWeatherMap(config);
  
  setInterval(() => {
    $('.country').text(weather.getCountry())
    $('.city').text(weather.getCity())
    $('.weather').html(weather.getWeatherDescription() + '<img src="' + weather.getWeatherIcon() + '" \/>');
    $('.temp').text(weather.getTemp() + weather.getUnitSymbol())
    $('.pressure').text(weather.getPressure())
    $('.humidity').text(weather.getHumidity())
    $('.windspeed').text(weather.getWindspeed())
  }, 3000);
});

License

MIT © Jay Looney <jay.m.looney@gmail.com>

About

Isomorphic Access to OpenWeatherMap API

License:MIT License


Languages

Language:JavaScript 100.0%