diff --git a/app.vue b/app.vue index 5deb6cb..42e4887 100644 --- a/app.vue +++ b/app.vue @@ -3,12 +3,11 @@ import type { FormError } from '#ui/types' const state = reactive({ url: undefined, - headerName: undefined, - headerValue: undefined, + headers: [], }) -const hasHeader = ref(false) const rawSchema = ref('') +const errorSchema = ref(null) const loading = ref(false) function validate(state: any): FormError[] { @@ -16,13 +15,13 @@ function validate(state: any): FormError[] { if (!state.url) errors.push({ path: 'url', message: 'Required' }) - if (hasHeader.value) { - if (!state.headerName) - errors.push({ path: 'headerName', message: 'Required' }) + // if (hasHeader.value) { + // if (!state.headerName) + // errors.push({ path: 'headerName', message: 'Required' }) - if (!state.headerValue) - errors.push({ path: 'headerValue', message: 'Required' }) - } + // if (!state.headerValue) + // errors.push({ path: 'headerValue', message: 'Required' }) + // } return errors } @@ -30,7 +29,8 @@ function validate(state: any): FormError[] { async function onSubmit() { rawSchema.value = '' loading.value = true - const { data } = await useAsyncData(() => getSchema(state)) + const { data, error } = await useAsyncData(() => getSchema(state)) + errorSchema.value = error.value if (!data.value) return loading.value = false @@ -38,10 +38,6 @@ async function onSubmit() { loading.value = false } -const headerValuePlaceholder = computed( - () => (Math.random() + 1).toString(36).substring(2), -) - useHead({ htmlAttrs: { lang: 'en', @@ -50,8 +46,7 @@ useHead({