Nuxt/examples/app/error-handling/server/middleware/error.ts
Clément Ollivier 1a7b570c82
docs(examples): add examples to docs (#3966)
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
2022-03-30 17:59:28 +02:00

9 lines
198 B
TypeScript

import { useQuery, defineMiddleware } from 'h3'
export default defineMiddleware((req, res, next) => {
if ('api' in useQuery(req)) {
throw new Error('Server middleware error')
}
next()
})