node.js - 如何获取post请求返回response的值?
问题描述

getUser: function (sessionId) {fetch(’/account_auth_admin_new_test/personal-api.accessLogin’, { method: ’POST’, headers: {’Content-Type’: ’application/json’ }, body: JSON.stringify({sessionId: sessionId,enterpriseCode: 'SUNEEE',clientIp: '127.0.0.1',encryptCode:'1234567899876543',appCode: 'XIANGPU' })}).then(function(res){ console.log(res.json())}).then(function(err){ console.log(’错误’,err)}) }
fetch模块:https://github.com/github/fetch
问题解答
回答1:getUser: function (sessionId) { fetch(’/account_auth_admin_new_test/personal-api.accessLogin’, {method: ’POST’,headers: { ’Content-Type’: ’application/json’},body: JSON.stringify({ sessionId: sessionId, enterpriseCode: 'SUNEEE', clientIp: '127.0.0.1', encryptCode:'1234567899876543', appCode: 'XIANGPU'}) }).then(function(res){return res.json() }).then(function(json) {console.log(’parsed json’, json) }).catch(function(ex) {console.log(’parsing failed’, ex) }).then(function(err){console.log(’错误’,err) })}
相关文章:
1. css - transform-origin 旋转参考点2. ubuntu系统php+apache web服务器异步方法不执行回调请教3. android 微信是如何实现即时更新好友头像的4. linux - ubuntu14安装mongodb出错5. node.js - koa2 如何获取参数?6. node.js - vue项目build后,打开监听port没问题,但是刷新页面后就挂掉了7. Python中的内列表问题,真的很困惑8. java - 关于京东单点登录认证的问题9. javascript - 为什么我的vue里的router-link不起作用10. centos7 关闭firewall nginx还是不能访问

网公网安备