app.get('/api’, function(req, res){ // req 参数代表所有发送到服务端的请求 // res 参数代表服务端向浏览器端发送的所有内容 var body = 'API name : '+req.query.name if (req.query.name == ‘loding’) { var user = require(‘./app/model/user’); var scr = user.loding(req.body.un,req.body.pw,req.body.at,req.body.tp); res.send(scr); }; });
/user.js/ exports.loding(var username,var password,var verification_code,var type) { if(type == ‘0’){//username return "username"; } else if(type == ‘1’){//email return "email"; } else if(type == ‘2’){//uid return "uid"; } return "worried"; };