The new handler.
import createServer, { json } from '@egomobile/http-server'
import { handleApiParseError } from '@egomobile/api-utils'
const app = createServer()
const myParseErrorHandler = handleApiParseError()
app.post(
'/',
[json({ onParsingFailed: myParseErrorHandler })],
async (request, response) => {
// at this point, JSON data has been parsed successfully
// and is stored in 'request.body'
}
)
// ...
app.listen()
.catch(console.error)
Generated using TypeDoc
Creates a new function, which handles parse errors.