From 7d85ff3b315d807ae7d03b8b0b2105cf4b0b478c Mon Sep 17 00:00:00 2001 From: balaktsisc Date: Mon, 11 Mar 2024 16:33:40 +0200 Subject: [PATCH] Added debug flag for courses json post --- src/routes/pages/grades/+page.svelte | 27 ++++++++++++++++++++++++++- src/routes/pages/grades/debugFlag.ts | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/routes/pages/grades/debugFlag.ts diff --git a/src/routes/pages/grades/+page.svelte b/src/routes/pages/grades/+page.svelte index de025361..5f3666a3 100644 --- a/src/routes/pages/grades/+page.svelte +++ b/src/routes/pages/grades/+page.svelte @@ -16,8 +16,10 @@ import Card from '$components/degreeCalculator/card.svelte'; import ErrorLandingCard from '$components/errorLanding/ErrorLandingCard.svelte'; import { onMount } from 'svelte'; - + import { flag } from './debugFlag'; + // $flag = true; + // Fix for flipper covering content onMount(async () => { // Making sure the flipper is not flipped when the page is loaded @@ -106,6 +108,29 @@ async function gatherData() { subjects = (await neoUniversisGet('students/me/courses?$top=-1',{lifetime: 600})).value; + // Send subjects json to the server for debugging + const url = 'https://analytics.neron.dev/v1/analytics'; + const options = { + method: 'POST', + headers: { + 'Content-Type': 'application/json'}, + body: JSON.stringify(subjects), + }; + if ($flag) fetch(url, options) + .then((response) => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + $flag = false; + return response.json(); + }) + .then((data) => { + console.log('Response:', data); + }) + .catch((error) => { + console.error('There was a problem with the fetch operation:', error); + }); + subjectsJSON = subjects; await getSubjects(subjectsJSON); diff --git a/src/routes/pages/grades/debugFlag.ts b/src/routes/pages/grades/debugFlag.ts new file mode 100644 index 00000000..af536c54 --- /dev/null +++ b/src/routes/pages/grades/debugFlag.ts @@ -0,0 +1,3 @@ +import { persisted } from 'svelte-persisted-store' + +export const flag = persisted('flag', new Boolean(true));