Skip to content

Commit

Permalink
docs(examples): fix error handling example (nuxt#18434)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlexLichter authored Jan 22, 2023
1 parent 2af6cc8 commit 625022c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions examples/app/error-handling/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>Index</h1>
</template>
3 changes: 3 additions & 0 deletions examples/app/error-handling/pages/other.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>Other</h1>
</template>
7 changes: 3 additions & 4 deletions examples/app/error-handling/server/middleware/error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getQuery, defineMiddleware } from 'h3'
import { getQuery, defineEventHandler } from 'h3'

export default defineMiddleware((req, res, next) => {
if ('api' in getQuery(req)) {
export default defineEventHandler((event) => {
if ('api' in getQuery(event)) {
throw new Error('Server middleware error')
}
next()
})

0 comments on commit 625022c

Please sign in to comment.