我正在使用js fetch()函数访问我的api,但出现错误
POST mywebsite net :: ERR_HTTP2_PROTOCOL_ERROR
我的api与我的android应用程序完美配合,当我在标题中添加不记名令牌时出现此错误
call(url, formBody, callback) {
const requestOptions = {
method: 'POST',
headers: this.getHeader(),
body: formBody,
redirect: 'follow'
};
fetch(url, requestOptions)
.then(response => response.text())
.then(result => {
callback(result)
})
.catch(error => {
console.log('error', error)
});
}getHeader() {
const myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer " + this.getValidToken())
return myHeaders;
}
我尝试了xmlhttprequest这是相同的错误