cari

Rumah  >  Soal Jawab  >  teks badan

node.js - Bagaimana untuk mendapatkan nilai respons yang dikembalikan melalui permintaan pos?

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

mengambil modul: https://github.com/github/fetch

怪我咯怪我咯2746 hari yang lalu1101

membalas semua(1)saya akan balas

  • 大家讲道理

    大家讲道理2017-05-19 10:50:09

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

    balas
    0
  • Batalbalas