From 625022cf28813dac36500bad5d1278ec75ea059c Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sun, 22 Jan 2023 16:42:08 +0100 Subject: [PATCH] docs(examples): fix error handling example (#18434) --- examples/app/error-handling/pages/index.vue | 3 +++ examples/app/error-handling/pages/other.vue | 3 +++ examples/app/error-handling/server/middleware/error.ts | 7 +++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/app/error-handling/pages/index.vue b/examples/app/error-handling/pages/index.vue index e69de29bb2..8729197b37 100644 --- a/examples/app/error-handling/pages/index.vue +++ b/examples/app/error-handling/pages/index.vue @@ -0,0 +1,3 @@ + diff --git a/examples/app/error-handling/pages/other.vue b/examples/app/error-handling/pages/other.vue index e69de29bb2..95aef348c6 100644 --- a/examples/app/error-handling/pages/other.vue +++ b/examples/app/error-handling/pages/other.vue @@ -0,0 +1,3 @@ + diff --git a/examples/app/error-handling/server/middleware/error.ts b/examples/app/error-handling/server/middleware/error.ts index 8977ed8efd..3400a60cf7 100644 --- a/examples/app/error-handling/server/middleware/error.ts +++ b/examples/app/error-handling/server/middleware/error.ts @@ -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() })