wip: shopping cart

This commit is contained in:
Nikita Kiselev
2025-07-23 18:40:57 +03:00
parent bb2ee38118
commit 49d41747d3
22 changed files with 545 additions and 141 deletions

View File

@@ -1,11 +1,26 @@
import {$fetch} from "ofetch";
import {ofetch} from "ofetch";
const BASE_URL = '/';
export const apiFetch = ofetch.create({
onRequest({ request, options }) {
const initData = window.Telegram?.WebApp?.initData
if (initData) {
options.headers = {
...options.headers,
'X-Telegram-InitData': initData,
}
}
},
});
export default async function (action, query = null, json = null) {
return await $fetch(`${BASE_URL}index.php?route=extension/tgshop/handle&api_action=${action}`, {
const options = {
method: json ? 'POST' : 'GET',
query: query,
body: json,
});
}
if (query) options.query = query;
if (json) options.body = json;
return await apiFetch(`${BASE_URL}index.php?route=extension/tgshop/handle&api_action=${action}`, options);
};