Created
February 7, 2022 09:04
-
-
Save killshot13/39b15fea833e843ee34571464653af8d to your computer and use it in GitHub Desktop.
Sample express.route config with nested GET, POST, PUT, & DELETE routes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app | |
.route('/api') | |
.get((req, res) => { | |
res.setHeader('Cache-Control', 'no-cache,no-store,max-age=0,must-revalidate') | |
res.setHeader('Pragma', 'no-cache') | |
res.setHeader('Expires', '-1') | |
res.send('The data was retrieved successfully!') | |
}) | |
.post((req, res) => { | |
res.setHeader('Cache-Control', 'no-cache,no-store,max-age=0,must-revalidate') | |
res.setHeader('Pragma', 'no-cache') | |
res.setHeader('Expires', '-1') | |
res.send('The data was saved successfully!') | |
}) | |
.put((req, res) => { | |
res.setHeader('Cache-Control', 'no-cache,no-store,max-age=0,must-revalidate') | |
res.setHeader('Pragma', 'no-cache') | |
res.setHeader('Expires', '-1') | |
res.send('The data was updated successfully!') | |
}) | |
.delete((req, res) => { | |
res.setHeader('Cache-Control', 'no-cache,no-store,max-age=0,must-revalidate') | |
res.setHeader('Pragma', 'no-cache') | |
res.setHeader('Expires', '-1') | |
res.send('The data was deleted successfully!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment