0
我不能夠解析數據從獲取調用從獲取文本反應本地fetch調用
下面就是該方法
onLoginPress=()=>{
console.log("username="+this.state.username);
console.log("password="+this.state.password);
this.sendLoginRequest(this.state.username,this.state.password)
.then((response) => {
console.log("RESPONSEEEEEEEEEEEEEEEE");
console.log(response.text())
console.log(Promise.resolve(response));
response.json();
})
.then((responseJson) => {
console.log(responseJson);
})
.catch((error) => {
console.error(error);
});
};
我得到它是一個承諾,我的反應無法從中獲得令牌。
下面是日誌response.text()
{ _45:0,_81:1, _65: ' 「3h8112qe2qobox3675ghmq9dtcbjvddc」', _54:空}
對於的console.log (Promise.resolve(response))輸出爲
{
_45: 0,
_81: 1,
_65: { type: 'default',
status: 200,
ok: true,
statusText: undefined,
headers: { map: { connection: [ 'Keep-Alive' ],
'content-length': [ '34' ],
'content-type': [ 'application/json; charset=utf-8' ],
'set-cookie': [ 'persistent_shopping_cart=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/' ],
'cache-control': [ 'no-store, no-cache, must-revalidate' ],
expires: [ 'Thu, 19 Nov 1981 08:52:00 GMT' ],
pragma: [ 'no-cache' ],
server: [ 'Apache/2.4.23 (Ubuntu)' ],
'keep-alive': [ 'timeout=5, max=100' ],
[ 'Tue, 20 Jun 2017 06:58:16 GMT' ] } },
url:'http://integration/customer/token',
_bodyInit: '"3h8112qe2qobox3675ghmq9dtcbjvddc"',
_bodyText: '"3h8112qe2qobox3675ghmq9dtcbjvddc"',
bodyUsed: true
},
_54: null }
responseJson返回undefined。
如何獲取令牌(3h8112qe2qobox3675ghmq9dtcbjvddc)中的數據。
謝謝!
謝謝。我工作。 –