@mugan86/openweather-api
Openweather Api Project in Node Typescript
Last updated a year ago by mugan86 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mugan86/openweather-api 
SYNC missed versions from official npm registry.

Openweather API (in working)

npm version Build Status Coverage Status Documentation

API Openweather with basic request.

Functions

Current Weather data.

  • By city name: Examples = ('Roma,it', 'Barcelona,es', 'Paris,fr', 'Bilbao,es' ,...)
  • By location: Example: {lat: 36.1699412, lng: -115.13982959999998} = Las Vegas
  • By zip code: Example: 89104 - Las Vegas

Forecast Weather data (Next 5 days in 3 hours period)

  • Pending to implement

Installation.

npm install @mugan86/openweather-api

Generate DIST

npm run watch

or

tsc -w

Usage

  • Register in Openweathermap.
  • Take API key from: API Keys
  • Follow this example. Basic example.

Imports

Typescript

import { ApiService } from '@mugan86/openweather-api';

const api = new ApiService('YOUR_API_KEY', 'm', 'es');

Javascript

const lib = require('@mugan86/openweather-api');
const apiService = lib.ApiService;

const api = new apiService('YOUR_API_KEY'); // unit metric = metres / lang = english

How to use

api.getCurrentWeather('city', ['Barcelona,es']).then(
    (data) => {
        console.log('***************** BARCELONA *****************');
        console.log(data)
    },
    (err) => console.error(err) // Show error in console);
);

api.getCurrentWeather('zip', ['89104']).then(
    (data) => { 
        console.log('***************** LAS VEGAS *****************');
        console.log(data)
    },
    (err) => console.error(err) // Show error in console);
);

api.getCurrentWeather('location', [{lat: 36.1699412, lon: -115.13982959999998}]).then(
    (data) => { 
        console.log('***************** LAS VEGAS *****************');
        console.log(data)
    },
    (err) => console.error(err) // Show error in console);
);

Build your project with Webpack

If you want to include this library inside a project builds with webpack for a client application, you must add this configuration inside your webpack configuration:

{
    target: "web",
    node: {
        fs: "empty",
        net: "empty",
        tls: "empty"
    }
}

Build your project with Webpack in Angular

If you want to include this library inside a project builds with webpack for a client application, you must add this configuration inside your webpack configuration. Go to node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js Go to file end and replace:

{
    plugins: extraPlugins,
    node: false
}

with

{
    plugins: extraPlugins,
    target: "web",
    node: {
        fs: "empty",
        net: "empty",
        tls: "empty"
    }
}

License

MIT

Current Tags

  • 2.1.4                                ...           latest (a year ago)

17 Versions

  • 2.1.4                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.1.0-beta                                ...           a year ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |