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. python3.5 urllib.parse.unquote 乱码2. html5 - node静态资源服务器设置了Cache-Control,但浏览器从来不走3043. android - ionic应用打包部署了,但是连接不上服务器,就连写一个a标签链接到百度都不可以4. mysql - 这里的sql语句该怎么写5. Mysql 关于 FOUND_ROWS() 和 ROW_COUNT() 函数6. mysql - msyql 判断字段不为空 简单方法7. mysql - laravel 子查询的问题8. 老师百度网盘分享一下WampServer的包啊,我们下载几kb要下载一天的.9. mysql中的collate关键字是什么意思?10. mysql - 使用update语句同时更新两个表的问题?
