Skip to content

Metode getRegenciesByProvince #32

Closed Answered by fityannugroho
cj-1010-1414 asked this question in Q&A
Discussion options

You must be logged in to vote

Untuk di library ini sendiri belum ada, karena tujuan utama library ini untuk kemudahan migrasi data ke database. Tapi kalau di API nya sudah ada, silakan lihat di dokumentasi repo idn-area.

Sebenarnya bisa saja kalau mau mengambil data semua regencies di suatu province, bisa memanfaatkan Array.filter seperti ini:

const getRegenciesByProvince = async (provinceCode) => {
  const regencies = await IdnArea.regencies({ transform: true });
  return regencies.filter(regency => regency.provinceCode === provinceCode);
};

Semoga bisa membantu.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fityannugroho
Comment options

Answer selected by cj-1010-1414
@cj-1010-1414
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants