import axios, { AxiosError, } from 'axios'; // Define a custom error type type RequestError = { message: string; // You can add more fields as needed, such as status, code, etc. }; export async function getPrayerTimeMethods(): Promise { const endpoint = 'http://api.aladhan.com/v1/methods'; try { const response = await axios.get( endpoint ); return response.data; } catch (error: | AxiosError | any) { const customError: RequestError = ( error as AxiosError ).response?.data || { message: ( error as AxiosError ).message, }; throw new Error( `Failed to fetch prayer time calculation methods: ${customError.message}` ); } } // Example usage: // getPrayerTimeMethods() // .then((data) => { // console.log(data); // }) // .catch((error) => { // console.error(error); // });