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

473
Views
res.status() vs. res.statusCode

I would like to know if these two different approach is it identical in expressjs?

 res.statusCode = 500;
 return res.json({
  status: "error"
 });

or

return res.status(500).json({
  status: "error"
});
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

expressjs - Response

the res object is an enhanced version of Node’s own response object and supports all built-in fields and methods.

res.status(code)

Sets the HTTP status for the response. It is a chainable alias of Node’s response.statusCode.

So the result is the same. expressjs just added a chainable version of statusCode.

over 4 years ago · Santiago Trujillo Report

0

Multiple status codes like status code 200, 404, and 500 in the same code? 200 for success, 404 for no data matching.

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!