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

234
Views
Express.js fetch API con objeto FormData

Tengo el siguiente bit de código en una vista

 var fd = new FormData(); fd.append("hello", "world"); fetch('/vision', { method: 'post', "content-type": "application/json; charset=utf-8", body: JSON.stringify({ hello: "world" }) }) .then(data => { debugger; })

y la acción a manejar

 visionRouter.post("/", (req, res) => { vision.detectText(imageUrl, (err, text) => { res.send(text); }) });

La ruta está siendo atacada, pero req.body no existe. ¿Cómo puedes usar fetch y FormData con express?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe utilizar el módulo de nodo body-parser . Instálalo así

 npm install body-parser

Luego en tu código haz esto

 var bodyParser = require("body-parser"); visionRouter.use(bodyParser.json());

Ahora su req.body podrá acceder a los datos JSON que está enviando

about 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!