在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ node調(diào)用第三方同步回調(diào)數(shù)據(jù)給前端

node調(diào)用第三方同步回調(diào)數(shù)據(jù)給前端

現(xiàn)在有以需求node需要調(diào)用第三方判斷是否登錄 登錄成功返回數(shù)據(jù)再返回給前端
await dataControl.getUserNickname(ctx.request.body.data.user).then(result=>{

                dataControl.getUserPassword(ctx.request.body.data.password).then(result=>{
                     let message={
                         type:ctx.request.body.type,
                        user:ctx.request.body.data.user,
                         password:ctx.request.body.data.password
                     };
                     dataPost.checkData(url,message).then(result=>{
                         console.log('result:',JSON.parse(JSON.parse(result).msg).data);
                         ctx.session = JSON.parse(JSON.parse(result).msg).data;
                         ctx.response.body = {
                             status: '201',
                             msg:'1'
                         };
                         console.log(ctx);
                     });
        
        
        
                 }).catch(err=>{
                     ctx.response.body = {
                        status: '201',
                         msg:'賬戶名或密碼錯誤1'
                    };
                })
        }).catch(err=>{
             ctx.response.body = {
                 status: '201',
                 msg:'賬戶名或密碼錯誤2'
             };
        });
        await dataPost.checkData();

當(dāng)數(shù)據(jù)寫在這個里邊時無法返回給前臺

dataPost.checkData(url,message).then(result=>{
console.log('result:',JSON.parse(JSON.parse(result).msg).data);

                         ctx.session = JSON.parse(JSON.parse(result).msg).data;
                         ctx.response.body = {
                             status: '201',
                             msg:'1'
                         };
                         console.log(ctx);
                     });

只有寫在外邊時才可以返回給前臺

   dataPost.checkData(url,message).then(result=>{                             

console.log('result:',JSON.parse(JSON.parse(result).msg).data);

                         ctx.session = JSON.parse(JSON.parse(result).msg).data;
                         
                     });
                     ctx.response.body = {
                             status: '201',
                             msg:'1'
                         };
                         console.log(ctx);
                       

但是寫在外邊就無法判斷是否登錄成功了 需要拿到數(shù)據(jù)后才執(zhí)行返回求大神救命搞了一天了

回答
編輯回答
久礙你

已經(jīng)解決了 自己解決了

2018年3月29日 20:05
編輯回答
過客

怎么解決的呢,我也碰到了這個問題,求幫助,謝謝啊

2017年9月26日 19:22