Lovika
Lovika

Reputation: 617

How response.end and response.send differs?

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');

Upvotes: 0

Views: 576

Answers (1)

Brooke Holmes
Brooke Holmes

Reputation: 1622

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.

Upvotes: 3

Related Questions