oak

How to access form body in oak/deno

拈花ヽ惹草 提交于 2021-01-28 21:34:32
问题 I'm using oak/deno. I have a form that is submitted from an ejs file served up. How do I access the form body? When I log it to the console, it prints: {type: "form", value: URLSearchParamsImpl {} } The post handler is shown below: router.post("/add", async (ctx: RouterContext) => { const body = (await ctx.request.body()) console.log(body) ctx.response.redirect("/"); }); 回答1: If you're sending x-www-form-urlencoded just use URLSearchParams instance available in body.value . body.value.get(