Fetch all districts and find the matching label for an okres code on an accounting unit.
Resolve a district code
Copy
Ask AI
// 1. Fetch all districtsconst { lokacie } = await fetch(`${BASE}/api/okresy`).then(r => r.json());// 2. Resolve the district label for an accounting unitconst district = lokacie.find(d => d.kod === unit.okres);// 3. Log the district labelconsole.log(district?.nazov?.sk);