toasts and body parse fixed
This commit is contained in:
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user