res.status(code)
This method sets the status code for the response.
Example
res.status(403).end();
res.status(400).send('Bad Request');
res.status(404).sendFile('/absolute/path/to/404.png')
index.js
'use strict' const express = require('express') const app = express() app.get('/', (req, res) => { res.status(200).send('Hello World') }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`))
Run index.js.
You can see below message.
No comments:
Post a Comment