// @TODO preimenuj v api.js, dodaj helperje se za json fetch / naš api export const useEtherpadApi = () => { const { baseUrl } = useRuntimeConfig().public const etherpadApiUrl = `${baseUrl}/etherpad-api` const etherFetch = (path, params) => { // Convert to form key-value pairs const formBody = Object.keys(params) .map(key => `${key}=${encodeURIComponent(params[key])}`) .join('&') // Call API return $fetch(etherpadApiUrl + path, { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}, body: formBody }) } return { etherpadApiUrl, etherFetch } }