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. mac里的docker如何命令行開啟呢?2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. nignx - docker內(nèi)nginx 80端口被占用4. docker容器呢SSH為什么連不通呢?5. 為什么我ping不通我的docker容器呢???6. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題7. angular.js使用$resource服務把數(shù)據(jù)存入mongodb的問題。8. docker-compose 為何找不到配置文件?9. javascript - 最近用echarts做統(tǒng)計圖時遇到兩個問題!!10. docker gitlab 如何git clone?

網(wǎng)公網(wǎng)安備