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

215
Views
Obtener Publicar un cuerpo de servidor de números indefinido

En el servidor no puedo obtener mi request.body.value pero no sé por qué. Siempre es indefinido. Ya probé mi otra función de búsqueda con un json. Y ha funcionado y son muy similares.

 app.use(express.urlencoded({ extended: true })); app.post('/async', (request, response) => { const size = request.body; console.log(size.value) let data = []; for (let i = 0; i < size.value; i++) { data.push(faker.fake("{{name.lastName}}" + " " + "{{name.firstName}}")) } response.send(JSON.stringify(data)) })
 async function sendAsync(event) { event.preventDefault(); let value = 15; let response = await fetch('/async', { method: "post", body: value }); if (!response.ok) throw new Error(response.statusText); let name = await response.json(); displayUserInfo(name); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

su request.body es el valor total que envió body: value . no es un objeto

1- tratarlo como un valor directamente

 app.post('/async', (request, response) => { const size = request.body; console.log(size) // here let data = []; for (let i = 0; i < size; i++) { //here data.push(faker.fake("{{name.lastName}}" + " " + "{{name.firstName}}")) } response.send(JSON.stringify(data)) })

o 2- envía un objeto que tiene una propiedad llamada value con el valor que quieres

 async function sendAsync(event) { event.preventDefault(); let value = 15; let response = await fetch('/async', { method: "post", body: {value} //here }); if (!response.ok) throw new Error(response.statusText); let name = await response.json(); displayUserInfo(name); }
about 4 years ago · Juan Pablo Isaza 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!