You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting an error when I use the readBody() function on a get Request. After checking out the implementation I realised that it's a normal behaviour as it is specified in the code :
I wonder why we want this specific behaviour, and not just return undefined like the function does for a POST request with no body.
I am not trying to make GET requests with a payload but I made a custom route array and registered them generically in my h3 router by looping on my array of routes so I use the readBody function for any routes no matter the verb.
I feel like I should be able to do this but if not, do you have any suggestions on how I should handle this ?
I dont want to have to write an if ('post' || 'put' || 'patch'....) because I'm not supposed to know what h3 considers as a "PayloadMethod".
Maybe h3 should expose a method isPayloadMethod() so that i can use readBody() onfy if the previous function returns true
Thank you for your answers
The text was updated successfully, but these errors were encountered:
Hello,
I am getting an error when I use the readBody() function on a get Request. After checking out the implementation I realised that it's a normal behaviour as it is specified in the code :
h3/src/utils/body.ts
Line 44 in 58e33ff
I wonder why we want this specific behaviour, and not just return undefined like the function does for a POST request with no body.
I am not trying to make GET requests with a payload but I made a custom route array and registered them generically in my h3 router by looping on my array of routes so I use the readBody function for any routes no matter the verb.
I feel like I should be able to do this but if not, do you have any suggestions on how I should handle this ?
I dont want to have to write an
if ('post' || 'put' || 'patch'....)
because I'm not supposed to know what h3 considers as a "PayloadMethod".Maybe h3 should expose a method
isPayloadMethod()
so that i can usereadBody()
onfy if the previous function returnstrue
Thank you for your answers
The text was updated successfully, but these errors were encountered: