Created
April 6, 2017 12:00
-
-
Save kisenka/b9c80c10afce02669de936c202892411 to your computer and use it in GitHub Desktop.
JSON server mock
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
const express = require('express'); | |
const data = require('./server-data.json'); | |
const server = express(); | |
const responseHeaders = { | |
'Content-Type': 'application/javascript', | |
'Access-Control-Allow-Origin': '*' | |
}; | |
server.get('/products/releases', (req, res) => { | |
const query = req.query; | |
const responseBody = JSON.stringify(data, null, 2); | |
res.status(200); | |
res.set(responseHeaders); | |
res.send(responseBody); | |
}); | |
server.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment