event
createServerData$
gqlCall
fetch
// /src/routes/decisions/(decisions).tsx...export function routeData() { return createServerData$( async () => { return await getUserDecisionsGQL(); }, );};...
// /src/db/requests/decision.tsx...export const getUserDecisionsGQL = async function () { const res = await gqlCall(GET_USER_DECISIONS); return res.data.getUserDecisions as Decision[];};...
// /src/lib/actions.tsxexport async function gqlCall(query: string, variables?: any) { // make graphql query try { const response = await fetch("http://localhost:3000/graphql", { method: "POST", body: JSON.stringify({ query, variables }), }); if (response?.ok) { // turn response into javascript object const gqlresponse = await response.json(); // return response return gqlresponse; } else { console.log(`HTTP Response Code: ${response?.status}`) // throw } } catch (error) { console.error('error:', error) }};