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

101
Views
Express ignora la llamada response.send()

Tengo un servidor simple. El código se explica a continuación:

 const express = require("express"); const app = express(); app.set("view engine", "hbs"); app.get("/about-me", function(_, response) { response.render("about_me.hbs"); }); app.get("/", function (_, response) { response.render("index.hbs"); }); app.all(/.*/, function (_, response) { // 404 page response.sendStatus(404); // set status code to 404 response.send("<h1>404 Not Found</h1>"); // send a body } app.listen(3000);

Pero cuando abrí http://localhost:3000/not-exist , apareció el texto "Not Foun<". ¿Por qué está pasando?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No puede enviar dos respuestas a una sola solicitud.

Utilice sendStatus o send .

Si desea controlar el código de estado cuando usa send , use status .

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!