Skip to content

Instantly share code, notes, and snippets.

@SaurusAraAra
Created May 19, 2026 18:16
Show Gist options
  • Select an option

  • Save SaurusAraAra/468297be09ab21fecd949b936f36a8c1 to your computer and use it in GitHub Desktop.

Select an option

Save SaurusAraAra/468297be09ab21fecd949b936f36a8c1 to your computer and use it in GitHub Desktop.
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