toasts and body parse fixed

This commit is contained in:
2026-01-20 19:56:20 +00:00
parent 8486b95a45
commit c020ea968c
2 changed files with 14 additions and 5 deletions

View File

@@ -23,13 +23,16 @@
loading_btn.value = true
await fetch("/settings/edit_user", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
first_name: user_data.value.first_name,
last_name: user_data.value.last_name,
email: user_data.value.email
})
}).then(async (response) => {
const body = await response.json()
}).then(async response => {
if (response.ok) {
toast.add({
title: "Done!",
@@ -38,9 +41,10 @@
})
}
else {
const body = await response.json()
toast.add({
title: 'Error',
description : body.statusMessage || body.message || 'Something went wrong',
description : body.data.detail || 'Something went wrong',
color: 'error'
})
}

View File

@@ -34,9 +34,12 @@
try {
fetch("/settings/changepw", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(pw_fields.value)
}).then(async (response) => {
const body = await response.json()
if (response.ok) {
toast.add({
title: "Done!",
@@ -45,9 +48,11 @@
})
}
else {
const body = await response.json()
console.log(body)
toast.add({
title: 'Error',
description : body.statusMessage || body.message || 'Something went wrong',
description : body.data.detail || 'Something went wrong',
color: 'error'
})
}