By doing this, even if the parameters were correct in a request, I was getting always an empty data argument.
I had to check the code of the library and realized that if you do that then the data argument for the handle methods is not the second argument, but the fourth, because the library passes as many arguments as the router.handle function receives, plus the data. It turns out that the fetch function receives not just the Request argument, but two additional ones: an Env and an ExecutionContext.
Based on an example of the itty router library I was doing:
By doing this, even if the parameters were correct in a request, I was getting always an empty
data
argument.I had to check the code of the library and realized that if you do that then the
data
argument for thehandle
methods is not the second argument, but the fourth, because the library passes as many arguments as therouter.handle
function receives, plus thedata
. It turns out that thefetch
function receives not just theRequest
argument, but two additional ones: anEnv
and anExecutionContext
.This works fine:
Thanks!