
const getOffersByName = async function getOffersByName(fileName:string) {
    const d = new Date();
    let time = d.getTime();
    const config = useRuntimeConfig();
    const res = await $fetch(config.public.apiBase + '/' + fileName +'.json?' + time )
        .catch((error) => error.data);
    return res;
}

const getOffersById = async function getOffersById(id: integer) {
    let response = null;
    const config = useRuntimeConfig();
    const d = new Date();
    const time = d.getTime();
    const res = await $fetch(config.public.apiBase + '/' + 'offers.json?' + time )
        .catch((error) => error.data);
    if (res.data && res.data.length > 0) {
        for(let item of res.data){
            if(item.id == id) response = item;
        }
    }
    return response;
}

export default {
    getOffersByName: getOffersByName,
    getOffersById: getOffersById,
    offers: "offers"
}