久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

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

瀏覽:143日期: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格式的字符串即可

主站蜘蛛池模板: 新泰市| 广灵县| 卢湾区| 南宁市| 苍梧县| 治县。| 台前县| 喀喇沁旗| 昌平区| 沙洋县| 宁津县| 泽普县| 理塘县| 兴城市| 宣威市| 阜平县| 水城县| 岳普湖县| 杭州市| 新津县| 彰化市| 通河县| 封开县| 合水县| 德惠市| 棋牌| 胶州市| 遂川县| 中山市| 高唐县| 蒙城县| 上虞市| 连云港市| 维西| 洪雅县| 伊川县| 长丰县| 甘谷县| 武汉市| 磴口县| 大新县|