Skip to content

Instantly share code, notes, and snippets.

@kisenka
Created April 6, 2017 12:00
Show Gist options
  • Save kisenka/b9c80c10afce02669de936c202892411 to your computer and use it in GitHub Desktop.
Save kisenka/b9c80c10afce02669de936c202892411 to your computer and use it in GitHub Desktop.
JSON server mock
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