Refactor get/add workouts for user endpoint, and update message on completion of workout

This commit is contained in:
Peter Stockings
2023-10-20 18:40:40 +11:00
parent 5423f8b8bb
commit f801c3c615
2 changed files with 75 additions and 12 deletions

View File

@@ -215,17 +215,17 @@
// Disconnect from heart rate sensor
disconnectHeartRateMonitor();
fetch("{{ url_for('workouts', user_id=user.id) }}", {
fetch("{{ url_for('create_workout', user_id=user.id) }}", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ cadence_readings: workoutData, heart_rate_readings: heartRateData }),
}).then(res => res.json())
.then(res => {
}).then(res => res.text())
.then(txt => {
workoutData = [];
swal("Submitted", JSON.stringify(res), "success");
swal("Submitted", txt, "success");
})
.catch(err => swal("Failed to submit workout", err.message, "error"));