환경
package.json
{
"name": "test-mock-server",
"main": "app.js",
"packageManager": "yarn@3.2.1",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.1"
}
}
app.js
var express = require("express");
var cors = require("cors");
var app = express();
app.listen(4000, () => {
console.log("Server running on port 4000");
});
app.use(cors());
app.get("/testList", (req, res, next) => {
res.json({
data: {
list: [
{
no: 1,
name: "Inga",
city: "Izmail",
price: 39757,
},
{
no: 2,
name: "Janna",
city: "Shillong",
price: 85111,
},
{
no: 3,
name: "Garrison",
city: "Ghanche",
price: 54681,
}
],
},
});
});
서버 기동