首页 >Node.js讨论组 >node.js - 如何获取post请求返回response的值?

node.js - 如何获取post请求返回response的值?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
 
+1
-1
 
分享
全部回复 (1)我来回答
    大家讲道理
    0楼
    大家讲道理 · 6个月前

    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)
        })
    }

      赞+0添加回复

    首页上一页1下一页尾页