14th May 2025 at 1:43am
ignorestate.datawill be undefined.state.readerwill be draining or already closed.streamstate.datawill be undefined. You must callstate.readerto get the request.bufferstate.datawill be a Buffer.stringstate.datawill be a string.jsonstate.datawill be read as a string, same asstringand then parsed as JSON, with some sanity checks. If the string is zero-length, undefined will be returned without attempting to parse. This is the only case where undefined can be returned. If the JSON fails to parse, a400 INVALIDresponse will be sent.__proto__andconstructor.prototypeare also checked.www-form-urlencodedandwww-form-urlencoded-urlsearchparams- Parse the body using
URLSearchParamsoptionally callingObject.entrieson it. -
const data = state.data = new URLSearchParams((await state.readBody()).toString("utf8"));if (state.bodyFormat === "www-form-urlencoded") state.data = Object.fromEntries(data);