Skip to content
Snippets Groups Projects
Commit a5f12a9c authored by hollum's avatar hollum
Browse files

get goal though uri

parent a711426a
No related branches found
No related tags found
No related merge requests found
......@@ -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>/",
......
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment