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. javascript - 微信小程序 如何实现这种左滑动出现删除的办法?有相关api吗?2. web服务器 - ubuntu下布置apache加wsgi加python3. tp6 事务闭包操作问题4. 主从复制 - MySQL 主从延迟 300s 以上,求大神解答5. python打开.py文件的时候出现window无法打开该文件是怎么回事呢?6. javascript - sublime快键键问题7. css - 图片的宽度发生变化而高度却没有相应变?8. docker 17.03 怎么配置 registry mirror ?9. dockerfile - 为什么docker容器启动不了?10. docker gitlab 如何git clone?

网公网安备