0

Hi I am trying to build a simple application using express js. I am new to node and express js. Can somebody explain the difference in response.end and response.send

I tried this command and both sent the request(message) to the Server.

res.send('Send the message');
res.end('send the message');
Lovika
  • 577
  • 2
  • 10
  • 21
  • Possible duplicate of [What is the difference between res.end() and res.send()?](https://stackoverflow.com/questions/29555290/what-is-the-difference-between-res-end-and-res-send) – JK. Jun 30 '18 at 04:41

1 Answers1

3

res.send() is a method built into express, and will make it automatically assume a Content-Type of html.

res.end(), on the other hand, just uses the underlying end() implementation built into nodejs on the response stream (aka. not express), so it doesn't attempt to assume the Content-Type.

Sam Holmes
  • 1,594
  • 13
  • 31