-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (26 loc) · 802 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//npm i --save express body-parser
//create-react-app client
//cd client
//yarn start
const express = require( 'express')
const bodyParser = require('body-parser')
app = express();
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false})) // receber requisicoes post
app.get('/',function(req,res){
res.send('funcionando');
})
const rotas = require('./rotas')
app.use('/api', rotas);
const port = 3001;
//Integrando back-end com front-end
app.use(express.static(__dirname + '/client'))
//tem que adicionar o axios no client yarn add axios
// client -> src ->App.js
//import axios from 'axios';
// no Arquivo App.js
//no packge.json do client adicionar
// "proxy": "http://localhost:3001/api"
app.listen(port,()=>{
console.log('server running localhost', port)
})