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. html5 - 请问一下写H5的时候 你们都是兼容那些手机2. mysql连表排序3. 使用 CSS3 的 Media Query 浏览器会加载其他不同分辨率的 css 文件么4. javascript - 求助这种功能有什么好点的插件?5. linux - python 安装 Anaconda 环境变量问题请教6. css3中的 :hover只能应用于a标签不能用于其它标签吗(比如div或li之类的标签)7. python3.x - python多线程如何修改数据?8. javascript - node中为中间层如何解决跨域问题9. mysql插入文本如果是个sql语句就报错了10. javascript - 使用vue-cli有个报错ERR_INCOMPLETE_CHUNKED_ENCODING

网公网安备