You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cuba-weather-javascript

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuba-weather-javascript

Simple SDK for cuba_weather API

1.1.3
latest
Source
npmnpm
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Cuba Weather JavaScript

License: MIT

Application programming interface of the Cuba Weather project implemented in JavaScript.

Currently the weather information is obtained from the Cuban search engine www.redcuba.cu.

Install

npm install cuba-weather-javascript

You can also clone or download this repository and at the root of the project do:

git clone https://github.com/cuba-weather/cuba-weather-javascript.git

Test

npm test

Package Red Cuba Client

const { RCApiClient, RCWeather } = require('../index')
async function main() {
  let locationStr = 'Municipio Especial Isla de la Juventud'
  try {
    let res = await RCApiClient.get(locationStr)
    let weather = new RCWeather(res.data.data)
    console.log(weather.weathertoString())
  } catch (err) {
    let error = {
      status: err.response.status,
      statusText: err.response.statusText,
      locationStr,
    }
    console.log(error)
  }
}

main().catch(console.error)

Get weather from RDcuba by municipality

const {
  RCApiClient,
  RCWeather,
  RED_CUBA_SOURCE,
  MUNICIPALITIES,
  UtilsService,
} = require('../index')
async function main() {
  let locationStr = 'cerro'
  let municipality = MUNICIPALITIES.find(
    (municipality) => municipality.nameCured === locationStr
  )
  let bestSource = UtilsService.getBestDistanceByMunicipality(
    municipality,
    RED_CUBA_SOURCE
  )

  try {
    let res = await RCApiClient.get(bestSource.name)
    let weather = new RCWeather(res.data.data)
    console.log(weather.weathertoString())
  } catch (err) {
    console.log(err)
  }
}

main().catch(console.error)

Keywords

cuba-weather

FAQs

Package last updated on 16 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts