export default {
    async f(url, method, data = null, json = false) {
        const API = 'http://yarik.protasevich.fun/api/';

        let options = {
            method: method.toUpperCase(),
            mode: 'cors',
            headers: {

            }
        };

        if (json) options.headers["Content-Type"] = "application/json";

        if (method === "POST") {
            options.body = data;
        }

        let response = await fetch(`${API}${url}`, options);

        return await response.json();
    }
}