res.links(links)
Joins the links provided as properties of the parameter
to populate the response’s Link HTTP header field.
index.js
'use strict' const express = require('express') const app = express() app.get('/', (req, res) => { res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' }); res.send("Hello World") }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`))
Run index.js
Open the url ‘http://localhost:3000/’ in browser, you can
see Link in Response Header.
No comments:
Post a Comment