docs: use defineLazyHandler in wasm example (#5797)

This commit is contained in:
Cupid Valentine 2022-07-11 16:41:56 +08:00 committed by GitHub
parent c695f71ed3
commit ac4e09b36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,13 @@
import { useQuery, lazyHandle } from 'h3' import { defineLazyHandler } from 'h3'
export default lazyHandle(async () => { export default defineLazyHandler(async () => {
const { exports: { sum } } = await loadWasmInstance( const { exports: { sum } } = await loadWasmInstance(
// @ts-ignore // @ts-ignore
() => import('~/server/wasm/sum.wasm') () => import('~/server/wasm/sum.wasm')
) )
return (req) => { return (event) => {
const { a = 0, b = 0 } = useQuery(req) const { a = 0, b = 0 } = useQuery(event)
return { sum: sum(a, b) } return { sum: sum(a, b) }
} }
}) })