biraz daha geliştirme

This commit is contained in:
2026-07-28 12:20:24 +03:00
parent ffd022ebe1
commit 73fd2a81a4
5 changed files with 162 additions and 114 deletions
+15 -5
View File
@@ -1,9 +1,19 @@
export async function fetchPrayerTimes(cityName = "Istanbul") {
export async function fetchPrayerTimes(cityName = "Istanbul", lat, lon) {
try {
const url =
"https://api.aladhan.com/v1/timingsByCity?city=" +
encodeURIComponent(cityName) +
"&country=Turkey&method=2";
let url;
if (lat !== undefined && lon !== undefined) {
url =
"https://api.aladhan.com/v1/timings?latitude=" +
encodeURIComponent(lat) +
"&longitude=" +
encodeURIComponent(lon) +
"&method=13";
} else {
url =
"https://api.aladhan.com/v1/timingsByCity?city=" +
encodeURIComponent(cityName) +
"&country=Turkey&method=2";
}
const res = await fetch(url);
if (!res.ok) {
throw new Error("Namaz vakitleri alınamadı");