国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

node.js - 如何用nodejs寫一個接口,隨便寫一個就好

瀏覽:150日期:2024-07-20 10:00:16

問題描述

node.js - 如何用nodejs寫一個接口,隨便寫一個就好

在個人主頁這里面,新手求教

問題解答

回答1:

去看官網(wǎng)文檔吧,用 express 或者 koa

回答2:

router.post('/changePwd', (req, res, next) => { var oldPwd = req.body.oldPwd,newPwd = req.body.newPwd,uid = req.session.user.id; var ep = new EventProxy(); ep.fail(err => {logger.error('~update user password failed .', err);res.json({status: err.status || se.code.failed}); }); if (!oldPwd || !newPwd) {return ep.throw(se.error(se.code.paramIllegal)); } if(oldPwd == newPwd){return ep.throw(se.error(se.code.pwdSame)); } admin.findUserById(uid, ep.done(user => {if(user[0].password != encrypt.encrypt(oldPwd)){ return ep.throw(se.error(se.code.verifyFailed));}if(user[0].password == encrypt.encrypt(newPwd)){ return ep.throw(se.error(se.code.pwdSame));}admin.updatePassword(encrypt.encrypt(newPwd),uid,ep.done(count => { if(count > 0){res.json({status : se.code.success}); }else{res.json({status : se.code.failed}); }})); }));});回答3:

返回個json格式的字符串即可

主站蜘蛛池模板: 襄城县| 珠海市| 东至县| 鄂托克旗| 西和县| 天门市| 苍南县| 浪卡子县| 云浮市| 册亨县| 基隆市| 韶山市| 梁河县| 钟山县| 香格里拉县| 青浦区| 静乐县| 古浪县| 延安市| 木里| 蕉岭县| 犍为县| 泉州市| 子长县| 罗城| 余江县| 夹江县| 连州市| 广河县| 平江县| 兰考县| 广元市| 柳江县| 新安县| 府谷县| 桂阳县| 大连市| 武安市| 松滋市| 遵化市| 略阳县|