【发布时间】:2018-01-31 15:38:49
【问题描述】:
我想知道是否可以在 React Native 中将摘要身份验证作为标头与 Fetch 一起使用?或者,还有其他选择吗?我尝试了以下方法:
const headers = new Headers();
headers.append("Authorization", "Digest " + ("username:password"));
return fetch(`url`,{
headers: {
headers,
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then((response) => response.json())
.then((responseJson) => {
console.log("checked if on local server response")
return responseJson;
})
.catch((error) => {
console.log('checked if on local server response error')
});
【问题讨论】:
标签: react-native fetch-api digest-authentication