indonesia-js

0.1.2 • Public • Published

Indonesia Administrative Area

Installation

Install with npm

npm i indonesia-js

or with yarn

yarn add indonesia-js

Usage

Province

Get all province

const { province } = require('indonesia-js');

province.all().then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get province data

const { province } = require('indonesia-js');

const id = 34;

province.findOne(id).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Or with thier descendants

province.findOne(id, ['regency']).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Available descendants: regency, district and village

Regency

Get all regency

const { regency } = require('indonesia-js');

regency.all().then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get regencies by province id

const { regency } = require('indonesia-js');

regency.findByProvinceId(34).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get regency data

const { regency } = require('indonesia-js');

const id = 3404;

regency.findOne(id).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Or with thier descendants

regency.findOne(id, ['district']).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Available descendants: district and village

District

Get all district

const { district } = require('indonesia-js');

district.all().then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get districts by regency id

const { district } = require('indonesia-js');

district.findByRegencyId(3404).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get district data

const { district } = require('indonesia-js');

const id = 3404120;

district.findOne(id).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Or with thier descendants

district.findOne(id, ['village']).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Available descendants: village

Village

Get all village

const { village } = require('indonesia-js');

village.all().then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get villages by district id

const { village } = require('indonesia-js');

village.findByDistrictId(3404120).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Get village data

const { village } = require('indonesia-js');

const id = 3404120004;

village.findOne(id).then((data) => {
  // do something with data
}).catch((err) => {
  // do something with err
});

Tests

npm test

Contributing

Fork and create Pull Request

Credits

All of the csv file are from https://github.com/edwardsamuel/Wilayah-Administratif-Indonesia

Package Sidebar

Install

npm i indonesia-js

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

2.64 MB

Total Files

18

Last publish

Collaborators

  • ramadani