私はこのようなフェッチ要求を持っています。Fetch Apiから返されるPromiseオブジェクト内でエラー値を取得するにはどうすればよいですか?
fetch(deafaultUrl + '/v1/users/',
{
headers: {
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(userInfoParams)
})
.then(function(response) {
console.log(response);
console.log(response.json());
// not working never go into this function
response.json().then(function(value) {
console.log('access promise');
console.log(value); // "Success"
});
if (response.status !== 200 && response.status !== 201) {
throw new Error("Bad response from server");
}
})
.then(function(json){
console.log("succeed json re");
console.log(json);
dispatch(update_user(json));
})
だから私はこのconsole.log(response.json());
を慰めるとき、私はこの
を得たが、約束の機能は、ワークアウトをdoesnotのように思えます。
[[PromiseValue]]の中にエラーオブジェクトを取得するにはどうすればよいですか?
ありがとうございます!ここで
なぜダブル 'then'ですか? – Weedoze