Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
nodejs: Koa , form in pug gives undefined

I have a form in pug with just one input

form(action="/" method="POST")
 label Enter URL to shorten
 br
 input(name="url" type="url") 
 button(type="submit") Submit

I use koa-pug to get the input

async function handleForm (ctx) {
   console.log(ctx.request.body);
}

However this logs undefined

I also use koa-body as body parser

app.use(body());
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In your form, you are calling your koa backend with a POST method. So to get the body, you need to use something like co-body,

...
const parse = require('co-body');
...

async function handleForm (ctx) {
  let body = await parse(ctx);
  console.log(body);
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!