From 33fc26e0bc960c55e9432611ec391f6c859345c6 Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Sun, 18 Feb 2024 17:33:36 +0000 Subject: [PATCH] feat(extension): submit code to server --- extension/src/background.js | 18 +++++++++++++++++- extension/src/config.js | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/extension/src/background.js b/extension/src/background.js index 1877e39..00b4bbd 100644 --- a/extension/src/background.js +++ b/extension/src/background.js @@ -39,7 +39,23 @@ function interceptSubmit(details) { } console.log('request for activity', activityId, 'the code', code, 'was', codeCorrect ? 'correct' : 'incorrect'); - // TODO: Send data to server. + + const query = new URLSearchParams({ + date: activity.date, + time: activity.time, + activity: activity.name, + space: activity.space, + }); + + fetch('https://aci-api.ashhhleyyy.dev/api/codes?' + query, { + headers: { + 'content-type': 'application/json', + }, + body: JSON.stringify({ + code: activity.code, + success: codeCorrect, + }), + }).then(res => console.log('submitted code: ', res)).error(e => console.error('failed to submit code', e')); } function interceptCode(details) { diff --git a/extension/src/config.js b/extension/src/config.js index 057a8d0..ca7ffa8 100644 --- a/extension/src/config.js +++ b/extension/src/config.js @@ -1 +1,2 @@ -this.SERVER_URL = 'https://aci-api.ashhhleyyy.dev'; +//this.SERVER_URL = 'https://aci-api.ashhhleyyy.dev'; +this.SERVER_URL = 'http://localhost:8000';