h3
h3 copied to clipboard
Better error handling when using a 'post' utility on a non-post method
Describe the feature
If you have the following handlers
export default defineEventHandler(async (event) => {
const body = await readBody(event)
const headers = getRequestHeaders(event)
return headers
})
and make a GET call to this route, you will get the following error:
This method is obtuse and doesnt help you understand what the issue is.
Its a silly mistake but was non-obvious that this is a problem
Additional information
- [X] Would you be willing to help implement this feature?