biraz daha geliştirme
This commit is contained in:
@@ -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ı");
|
||||
|
||||
Reference in New Issue
Block a user