Skip to content
Discussion options

You must be logged in to vote

Yeah, your problem happened cuz get requests don’t normally have a body, and postman, along with probably most http clients, either strip it or don’t send it in a way that hono expect. It’s probably best to switch the route method to post, as body parsing works reliably with it.

But if you really need to send a body with a get request, you'd need to bypass the default body parser behaviors.

practiceRouter.get("/status-batch", async (c) => {
  const raw = await c.req.text();
  const body = JSON.parse(raw || "{}");
  // ------------------------
});

However, this would still probably fail on most clients that refuse to send a body with get requests.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lyoko-Jeremie
Comment options

Answer selected by Lyoko-Jeremie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants