var express =require('express');var app =express();app.listen(3000,function () {console.log('Example app listening on port 3000!');});//要先 listen 才會有localhost:3000這個 portapp.get('/',function(req,res){res.send('input [localhost:3000/get/All] to get All Data')});app.get('/get/All',asyncfunction (req, ApiRes) {ApiRes.send('You get All Data')//上面是單純 server 架好後// localhost:3000/get/All 會得到一個 You get All Datatry {var prodSchemaObj =require("./prodSchema.js");constDbRes=awaitprodSchemaObj.find({}).lean().sort({index:1}).exec();ApiRes.json({ success:true, data: DbRes }); }catch (e) {ApiRes.json({ success:false, message:e.message })console.error(e.stack); }//try catch 部分為「想經由輸入某段 API 得到 Data」});