changed functions for nuxt-friendly version
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import * as z from 'zod'
|
||||
import type { FormSubmitEvent } from '@nuxt/ui'
|
||||
import urlJoin from 'url-join'
|
||||
|
||||
definePageMeta({
|
||||
layout: "settings",
|
||||
@@ -9,7 +10,7 @@
|
||||
const loading_btn = ref(false)
|
||||
const toast = useToast()
|
||||
const config = useRuntimeConfig()
|
||||
const base_url = config.app.baseURL.endsWith('/') ? config.app.baseURL.slice(0, -1) : config.app.baseURL
|
||||
//const base_url = config.app.baseURL.endsWith('/') ? config.app.baseURL.slice(0, -1) : config.app.baseURL
|
||||
|
||||
|
||||
const schema = z.object({
|
||||
@@ -34,7 +35,7 @@
|
||||
async function submitChanges(event: FormSubmitEvent<Schema>) {
|
||||
loading_btn.value = true
|
||||
try {
|
||||
fetch(base_url + "/settings/changepw", {
|
||||
fetch(urlJoin(config.app.baseURL,"/settings/changepw"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -51,10 +52,10 @@
|
||||
}
|
||||
else {
|
||||
const body = await response.json()
|
||||
console.log(body)
|
||||
console.log(body.statusMessage || "")
|
||||
toast.add({
|
||||
title: 'Error',
|
||||
description : body.data.detail || 'Something went wrong',
|
||||
description : body.data?.detail || body.statusMessage || 'Something went wrong',
|
||||
color: 'error'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user