res.send() sends a response of virtually any type — a string, object, array, or Buffer —
and sets the Content-Type header automatically.
const express = require("express");
const app = express();
app.get("/ping", (req, res) => {
res.send("pong");
});
app.get("/info", (req, res) => {
res.send({ service: "Order Service", status: "healthy" });
});
app.listen(4600, () => console.log("Listening on 4600"));
Common uses
- Sending plain-text acknowledgements.
- Returning small JSON payloads without calling
res.json()explicitly. - Sending rendered HTML fragments.