h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Better error handling when using a 'post' utility on a non-post method

Open AdamBD opened this issue 1 year ago • 0 comments

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:

image

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?

AdamBD avatar Aug 08 '24 16:08 AdamBD