29 lines
563 B
JavaScript
29 lines
563 B
JavaScript
const express = require('express')
|
|
const app = express()
|
|
|
|
app.get('/back/jsonp', function(req, res) {
|
|
var fun = req.query.fun;
|
|
console.log("前端函数名为:"+fun)
|
|
var listdata = {
|
|
status: 200,
|
|
message: "nodejs 后端,请求成功",
|
|
data: [
|
|
{
|
|
id: 1,
|
|
title: "新闻1"
|
|
},
|
|
{
|
|
id: 2,
|
|
title: "新闻2"
|
|
}
|
|
]
|
|
};
|
|
|
|
res.end(`${fun}(${JSON.stringify(listdata)})`)
|
|
|
|
//getNodeJsData(listdata)
|
|
})
|
|
|
|
app.listen(3000, function() {
|
|
console.log('Example app listening on port 3000!')
|
|
}) |