From a5f12a9c9d3db02d0267ea4c7ac5d40e55c0f520 Mon Sep 17 00:00:00 2001
From: hollum <hollum@hotmail.com>
Date: Thu, 10 Mar 2022 09:45:36 +0100
Subject: [PATCH] get goal though uri

---
 backend/secfit/workouts/urls.py | 1 +
 frontend/www/scripts/goal.js    | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/backend/secfit/workouts/urls.py b/backend/secfit/workouts/urls.py
index a58f818..1ccbcd0 100644
--- a/backend/secfit/workouts/urls.py
+++ b/backend/secfit/workouts/urls.py
@@ -17,6 +17,7 @@ urlpatterns = format_suffix_patterns(
             name="workout-detail",
         ),
         path("api/goal/", views.GoalList.as_view(), name="goal-list"),
+        path("api/goal/<int:pk>/", views.GoalDetail.as_view(), name="goal-detail"),
         path("api/exercises/", views.ExerciseList.as_view(), name="exercise-list"),
         path(
             "api/exercises/<int:pk>/",
diff --git a/frontend/www/scripts/goal.js b/frontend/www/scripts/goal.js
index 7b86918..3cc22e7 100644
--- a/frontend/www/scripts/goal.js
+++ b/frontend/www/scripts/goal.js
@@ -112,10 +112,10 @@ async function deleteExercise(id) {
     }
 }
 
-async function retrieveExercise(id) {
-    let response = await sendRequest("GET", `${HOST}/api/exercises/${id}/`);
+async function retrieveGoal(id) {
+    let response = await sendRequest("GET", `${HOST}/api/goal/${id}/`);
 
-    console.log(response.ok)
+    console.log(response)
 
     if (!response.ok) {
         let data = await response.json();
@@ -220,7 +220,7 @@ window.addEventListener("DOMContentLoaded", async () => {
     // view/edit
     if (urlParams.has('id')) {
         const exerciseId = urlParams.get('id');
-        await retrieveExercise(exerciseId);
+        await retrieveGoal(exerciseId);
 
         editButton.addEventListener("click", handleEditExerciseButtonClick);
         deleteButton.addEventListener("click", (async (id) => await deleteExercise(id)).bind(undefined, exerciseId));
-- 
GitLab