rajaapi
v1.0.4
Published
raja api simple package
Downloads
132
Readme
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