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. SublimeText3汉化版安装2. navicat与MYSQL5.7搭配问题3. 前端 - css的加号是什么意思?4. javascript - 手机网页上实现调用相册或者拍照或者录制短视频上传,有没有人有做过相关功能,求告知,项目用,急!!!5. html5 - 如何让H5页面在手机浏览器里和微信全屏显示6. android - 类似于微信朋友圈图片这样的是在listview中嵌套gridview还是动态加入多个imageview呢?7. css - 使用blur()滤镜为什么有透明的效果8. MySQL客户端吃掉了SQL注解?9. mysql优化 - mysql 多表联合查询,求一个效率最高的查询10. html - 类似这样的弹层用什么插件写比较好?

网公网安备