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. android - 安卓activity无法填充屏幕2. 一个走错路的23岁傻小子的提问3. javascript - SuperSlide.js火狐不兼容怎么回事呢4. java - 为什么hibernate查询表集报错?5. android - 离线地图的这种列表该怎么实现?6. python - django 里自定义的 login 方法,如何使用 login_required()7. java - 安卓电视盒子取得了root权限但是不能安装第三方应用,请问该怎么办?8. android spinner改变下拉弹出的位置9. node.js - 函数getByName()中如何使得co执行完后才return10. java - 创建maven项目失败了 求解决方法
