docs(examples): fix error handling example (#18434)

This commit is contained in:
Alexander Lichter 2023-01-22 16:42:08 +01:00 committed by GitHub
parent 2af6cc84db
commit 625022cf28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,3 @@
<template>
<h1>Index</h1>
</template>

View File

@ -0,0 +1,3 @@
<template>
<h1>Other</h1>
</template>

View File

@ -1,8 +1,7 @@
import { getQuery, defineMiddleware } from 'h3' import { getQuery, defineEventHandler } from 'h3'
export default defineMiddleware((req, res, next) => { export default defineEventHandler((event) => {
if ('api' in getQuery(req)) { if ('api' in getQuery(event)) {
throw new Error('Server middleware error') throw new Error('Server middleware error')
} }
next()
}) })