toasts and body parse fixed
This commit is contained in:
@@ -23,13 +23,16 @@
|
|||||||
loading_btn.value = true
|
loading_btn.value = true
|
||||||
await fetch("/settings/edit_user", {
|
await fetch("/settings/edit_user", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
first_name: user_data.value.first_name,
|
first_name: user_data.value.first_name,
|
||||||
last_name: user_data.value.last_name,
|
last_name: user_data.value.last_name,
|
||||||
email: user_data.value.email
|
email: user_data.value.email
|
||||||
})
|
})
|
||||||
}).then(async (response) => {
|
}).then(async response => {
|
||||||
const body = await response.json()
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: "Done!",
|
title: "Done!",
|
||||||
@@ -38,9 +41,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const body = await response.json()
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
description : body.statusMessage || body.message || 'Something went wrong',
|
description : body.data.detail || 'Something went wrong',
|
||||||
color: 'error'
|
color: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,12 @@
|
|||||||
try {
|
try {
|
||||||
fetch("/settings/changepw", {
|
fetch("/settings/changepw", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
body: JSON.stringify(pw_fields.value)
|
body: JSON.stringify(pw_fields.value)
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
const body = await response.json()
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: "Done!",
|
title: "Done!",
|
||||||
@@ -45,9 +48,11 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const body = await response.json()
|
||||||
|
console.log(body)
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
description : body.statusMessage || body.message || 'Something went wrong',
|
description : body.data.detail || 'Something went wrong',
|
||||||
color: 'error'
|
color: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user