SamaraFellaDina / lose-your-head-the-client-case

Ontwerp en maak een website voor een opdrachtgever op basis van een Headless CMS API
https://lose-your-head-the-client-case-omega.vercel.app
MIT License
0 stars 2 forks source link

Sveltekit Installeren #23

Closed Khdulkadir closed 1 month ago

Khdulkadir commented 1 month ago

SvelteKit is op deze manier geinstalleerd op het project:

/**
 * An asynchronous helper function that wraps the standard node.js fetch API.
 * This function calls an API url passed as the first and mandatory parameter,
 * there is an optional payload parameter to send a json object, eg. a filter.
 * It then calls the API and returns the response body parsed  as a json object.
 * @example <caption>fetchJson as returning function using the await keyword</caption>
 * const data = await fetchJson('https://api-url.com/endpoint/')
 * @example <caption>fetchJson as oneliner using the then() structure.</caption>
 * fetchJson('https://api-url.com/endpoint/').then((data)=>{
 *  // use data...
 * })
 * @param {string} url the api endpoint to address
 * @param {object} [payload] the payload to send to the API
 * @returns the response from the API endpoint parsed as a json object
 */
export default async function fetchJson(url, payload = {}) {
  return await fetch(url, payload)
    .then((response) => response.json())
    .catch((error) => error)
}

export async function handle({ event, resolve }) { return await resolve(event, { filterSerializedResponseHeaders: (key, value) => { return key.toLowerCase() === 'content-type'; }, }); }


-static folder nieuwe mapjes toegevoegd: assets, styles, scripts, fonts