Last active
September 9, 2018 13:36
-
-
Save Roiseuxquentin/6e02b0e637b329522e2d6bef19669bd8 to your computer and use it in GitHub Desktop.
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 app = express() | |
const data = require('../data.json') | |
app.use((request, response, next) => { | |
response.header('Acsess-Control-Allow-Origin','*') | |
response.header('Access-Control-Allow-Headers','Origin, X-Requested-With,Content-Type,Accept') | |
next() | |
}) | |
app.get('/', (request, response) => { | |
response.send('go to data') | |
}) | |
app.get('/data', (request, response) => { | |
response.json(data) | |
}) | |
const afterServerStart = () => console.log('access to http://localhost:4242/') | |
app.listen(4242, afterServerStart) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment