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

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

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

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

問題描述

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

在個(gè)人主頁這里面,新手求教

問題解答

回答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:

返回個(gè)json格式的字符串即可

主站蜘蛛池模板: 柘城县| 兰考县| 泾阳县| 千阳县| 梁河县| 大方县| 惠水县| 马边| 新巴尔虎左旗| 五原县| 昭平县| 青岛市| 集贤县| 固原市| 资兴市| 嵊泗县| 西吉县| 巴林左旗| 宁海县| 边坝县| 石台县| 岳阳县| 宜兰市| 汝阳县| 广安市| 沙河市| 偃师市| 清丰县| 襄樊市| 淳安县| 巴彦淖尔市| 小金县| 江孜县| 博兴县| 全南县| 泽普县| 确山县| 高邮市| 嵩明县| 崇礼县| 来安县|