-
Notifications
You must be signed in to change notification settings - Fork 2
/
mock.js
32 lines (29 loc) · 967 Bytes
/
mock.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
const express = require('express')
const app = express()
app.get('/api/course/list', (req, res) => {
// res.setHeader('Access-Control-Allow-Origin','*')
// res.setHeader('Access-Control-Allow-Methods','GET,POST,DELETE,PUT')
// res.setHeader('Content-Type','application/json')
res.json({
code: 0,
list: [
{ name: 'http权威指南', id: 1 },
{ name: 'JS高级编程', id: 2 },
{ name: '算法', id: 3 },
{ name: '网络编程', id: 4 }
]
})
})
app.get('/api/user/info', (req, res) => {
// res.setHeader('Access-Control-Allow-Origin','*')
// res.setHeader('Access-Control-Allow-Methods','GET,POST,DELETE,PUT')
// res.setHeader('Content-Type','application/json')
res.json({
code: 0,
data: { title: 'web小白', best: '小白' }
})
})
// 端口在8082,前端请求8081端口
app.listen(8082, () => {
console.log('mock启动成功')
})