Created
May 19, 2026 18:16
-
-
Save SaurusAraAra/468297be09ab21fecd949b936f36a8c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require("axios") | |
| async function getJadwal(city = "Jakarta") { | |
| try { | |
| const { data } = await axios.get( | |
| `https://api.aladhan.com/v1/timingsByCity?city=${encodeURIComponent(city)}&country=Indonesia&method=2`, | |
| { timeout: 10000 } | |
| ) | |
| const t = data.data.timings | |
| const d = data.data.date.readable | |
| return { | |
| status: true, | |
| result: { | |
| city: city.toUpperCase(), | |
| date: d, | |
| imsak: t.Imsak, | |
| subuh: t.Fajr, | |
| terbit: t.Sunrise, | |
| dzuhur: t.Dhuhr, | |
| ashar: t.Asr, | |
| maghrib: t.Maghrib, | |
| isya: t.Isha, | |
| midnight: t.Midnight | |
| } | |
| } | |
| } catch (e) { | |
| return { | |
| status: false, | |
| message: "kota tidak ditemukan / api error" | |
| } | |
| } | |
| } | |
| (async () => { | |
| const res = await getJadwal("Jakarta") | |
| console.log(res) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment