Slightly smarter url retrieval in data

This commit is contained in:
jableader 2024-05-12 13:30:42 +10:00
parent 74e46eef11
commit 7123124aa6

View file

@ -1,4 +1,4 @@
const BASE_URL = "http://localhost:8000" const BASE_URL = window.location.href.replace(/^(http:\/\/[^/:]+).*/, "$1:8000")
let user = null; let user = null;
export default { export default {
@ -9,7 +9,7 @@ export default {
meal.meal_date = new Date(meal.meal_date); meal.meal_date = new Date(meal.meal_date);
} }
return meals; return meals.sort((a, b) => a.meal_date - b.meal_date);
}, },
async getMeal(id) { async getMeal(id) {
var response = await fetch(BASE_URL + `/meals/${encodeURIComponent(id)}`); var response = await fetch(BASE_URL + `/meals/${encodeURIComponent(id)}`);