JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q28616F
  • License ISC

Retrieve weather information based on user's location.

Package Exports

  • location-weather-info
  • location-weather-info/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (location-weather-info) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Location Weather Info

Retrieve current weather information based on user's location.

Features

Get user's current weather Information based on:

  • Co-ordinates (Latitude & Longitude)
  • City Name

Installation

Using npm:

$ npm install location-weather-info

Using yarn:

$ yarn add location-weather-info

Example

Step-1: Import LocationWeatherInfo after installation.

import LocationWeatherInfo from 'location-weather-info'

Step-2: Declare the constructor and pass your API KEY. Your can get your API_KEY from Open Weather Map. You must login to get your secret key. It is highly recommended to store your secret key into .env file.

const weather = new LocationWeatherInfo(API_KEY);

Step-3: Now you can get the current weather info based on Co-ordinates (Latitude & Longitude) or City Name.

//Get weather by Co-ordinates (latitude, longitude)
const weatherByCoords = weather.getWeatherByCoords(35, 139);
console.log(weatherByCoords);

//Get weather by City Name
const weatherByCity = weather.getWeatherByCity("Tokyo");
console.log(weatherByCity);

Output

If you pass the required arguments then you will get the response with an object like:

{success: true, data: weatherData}

If any error is occurred then the response will be:

{success: false, error: errorMessage}

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

Author

@SharifRahat