0.1.5 • Published 7 years ago

cwb-weather-assistant v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

cwb-weather-assistant

NPM version Build Status Coverage Status

Simple CWB client to fetch weather assistant for JavaScript

Install

$ npm install --save cwb-weather-assistant

Browser

Add a <script> to your index.html:

<script src="/node_modules/cwb-weather-assistant/dist/cwb-weather-assistant.min.js"></script>

Node.js / Webpack

Import the module to your *.js file:

const CWBClient = require('cwb-weather-assistant')

Usage

const cwb = new CWBClient(API_KEY)

Fetch all weather assistants of locations

cwb.fetch()
  .then(res => {
    console.log(res)  // result of the request
  })
  .catch(err => {
    console.log(err)
  })

Fetch a weather assistant of the location

cwb.fetch({ location: LOCATION })
  .then(res => {
    console.log(res)  // result of the request
  })
  .catch(err => {
    console.log(err)
  })

Get available LOCATION list

cwb.locations()  // an array for list of locations
LocationName
TAIPEI_CITY台北市
NEW_TAIPEI_CITY新北市
KEELUNG_CITY基隆市
HUALIEN_COUNTY花蓮縣
YILAN_COUNTY宜蘭縣
KINMEN_COUNTY金門縣
PENGHU_COUNTY澎湖縣
TAINAN_CITY台南市
KAOHSIUNG_CITY高雄市
CHIAYI_COUNTY嘉義縣
CHIAYI_CITY嘉義市
MIAOLI_COUNTY苗栗縣
TAICHUNG_CITY台中市
TAOYUAN_CITY桃園市
HSINCHU_COUNTY新竹縣
HSINCHU_CITY新竹市
PINGTUNG_COUNTY屏東縣
NANTOU_COUNTY南投縣
TAITUNG_COUNTY台東縣
CHANGHUA_COUNTY彰化線
YUNLIN_COUNTY雲林縣
LIENCHIANG_COUNTY連江縣

Reference

交通部中央氣象局-開放資料平臺

License

MIT © Chun-Kai Wang