rajaapi

1.0.4 • Public • Published

rapi

simple Raja api package for the browser and node.js

Features

  • get Data raja APi
  • Supports the Promise API
  • Automatic transforms for JSON data

Installing

Using npm:

$ npm i rajaapi

Example

Performing a GET request

const rapi = require('rajaapi')
 
const api = new rapi({ token: 'your token' })
 
//   get provinsi
api.rajaProvinsi()
  .then(data => {
    console.log(data)
  })
  .catch(Error => {
    console.log(Error)
  })
 
//   get kabupaten
  api.rajaKabupaten(51)
  .then(data => {
    console.log(data)
  })
  .catch(Error => {
    console.log(Error)
  })
 
//   get kecamatan
  api.rajaKecamatan(5103)
  .then(data => {
    console.log(data)
  })
  .catch(Error => {
    console.log(Error)
  })  
 
//   get kelurahan
    api.rajaKelurahan(5103010)
  .then(data => {
    console.log(data)
  })
  .catch(Error => {
    console.log(Error)
  })  
 
 
// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
  try {
    const response = await api.rajaKelurahan(5103010);
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}
getUser()

License

MIT

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i rajaapi

    Weekly Downloads

    14

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    5.27 kB

    Total Files

    6

    Last publish

    Collaborators

    • balinux