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. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!2. 前端 - css中关于设置透明度的问题,有点混乱3. docker绑定了nginx端口 外部访问不到4. 我在centos容器里安装docker,也就是在容器里安装容器,报错了?5. docker - 如何修改运行中容器的配置6. dockerfile - 我用docker build的时候出现下边问题 麻烦帮我看一下7. docker 下面创建的IMAGE 他们的 ID 一样?这个是怎么回事????8. docker start -a dockername 老是卡住,什么情况?9. 计算机 - 我学习了C语言,数据结构和一点点java基础,想自学C++,请问买什么入门书籍好?10. docker-compose 为何找不到配置文件?
