25 lines
701 B
JavaScript
25 lines
701 B
JavaScript
// const express = require('express')
|
|
// const app = express()
|
|
// const port = 3000
|
|
// app.all('*', function (req, res, next) {
|
|
// res.header('Access-Control-Allow-Origin', '*');
|
|
// res.header('Content-Type', 'application/json;charset=utf-8');
|
|
// next();
|
|
// });
|
|
|
|
app.get('/api/index', (req, res) => {
|
|
res.json({
|
|
title:'测试标题',
|
|
data: [
|
|
{title: '测试1', id:1},
|
|
{title: '测试2', id:2},
|
|
{title: '测试3', id:3},
|
|
{title: '测试4', id:4},
|
|
{title: '测试5', id:5},
|
|
{title: '测试6', id:6},
|
|
|
|
]
|
|
})
|
|
})
|
|
|
|
app.listen(port, () => console.log(`Example app listening on port ${port}!`)) |