我正在创建一个Web应用程序,该应用程序将接受用户输入并使用获取请求查询flask应用程序。有时,它可以正确运行,但是会随机返回以下错误消息。您能帮我解决此错误吗?
这是错误日志1
的图像This is an image of the chrome network tab error
这是我的代码:
async loginClick() {
// exists represents whether or not the username was found in the Mongo database
let exists = await this.state.IS.checkExists(this.state.username);
alert('this compiles as expected');
console.log(exists);
if (exists === false) {
alert("Username not found!");
return;
}
/*** Returns True if user exists in database else false ***/
async checkExists(user) {
let data = {
'u_n': 'user',
'f_n': 'first',
'pass': 'pass',
};
let bool = false;
await Promise.resolve(
fetch(this.config.VERIFY_URL,
{
method: 'POST',
mode: 'cors',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip',
'Accept': 'application/json'
}
})).then(response =>
response.json()).then(json_msg => {
bool = json_msg.exists;
console.log(bool);
alert(bool);
return bool;
}).catch(error => console.error(error));
return bool;
}