Back4App在Chrome上给Parseerror 200

发布于 2025-01-29 17:26:17 字数 1142 浏览 4 评论 0原文

我为使用Back4App的Web应用程序登录了一个数据库,它在Firefox-ish上起作用,但在Chrome上根本不起作用。在FF上,我尝试登录,它给了我一个解析错误200用户名/密码,我重新加载了页面并起作用(我不知道为什么它会这样做,我也想解决这个问题)。然而,每当我重新加载它只是清除了字段并且不让我进去时,同样的技巧在Chrome上都不起作用。 我查找了错误,事实证明,出于某种原因,邮政请求不会从输入字段中获取信息。 这是登录窗口的html:

<dialog id="login">
  <h1>تسجيل دخول</h1>
  <input type="text" id="loginid" placeholder="id" pattern="[A-Za-z]">
  <input type="password" id="loginpass" placeholder="password">
  <button type="submit" id="loginButton">دخول</button>
</dialog>

那是背后的JS,它是香草

const login = document.querySelector('#login');
let loginid = document.querySelector('#loginid').value;
let loginpass=document.querySelector('#loginpass');
const loginButton = document.querySelector('#loginButton');
login.style.display='block';
loginButton.onclick = function() {
let user=Parse.User.logIn(loginid,loginpass.value).then(function(user){
  alert(`Welcome ${user.get('username')}`);
  login.style.display='none';
  membersDiv.style.display='block';
  addMemberArea.style.display='block';
}).catch(function(error){
  alert(error);
})
}

I made a database for accounts login for a web app with back4app, it works on Firefox-ish but doesn't work on Chrome at all. on FF, I try to log in and it gives me a parse error 200 username/password required, I reload the page and it works (I don't know why it does that btw and I want to fix that too). The same trick however doesn't work on Chrome, whenever I reload it just clears the fields and doesn't let me in.
I looked up the error, and it turns out that the post request doesn't take the info from the input fields for some reason.
Here's the login window's HTML:

<dialog id="login">
  <h1>تسجيل دخول</h1>
  <input type="text" id="loginid" placeholder="id" pattern="[A-Za-z]">
  <input type="password" id="loginpass" placeholder="password">
  <button type="submit" id="loginButton">دخول</button>
</dialog>

and that's the JS behind it, it's vanilla by the way

const login = document.querySelector('#login');
let loginid = document.querySelector('#loginid').value;
let loginpass=document.querySelector('#loginpass');
const loginButton = document.querySelector('#loginButton');
login.style.display='block';
loginButton.onclick = function() {
let user=Parse.User.logIn(loginid,loginpass.value).then(function(user){
  alert(`Welcome ${user.get('username')}`);
  login.style.display='none';
  membersDiv.style.display='block';
  addMemberArea.style.display='block';
}).catch(function(error){
  alert(error);
})
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极度宠爱 2025-02-05 17:26:17

看起来您正在使用Parse JavaScript SDK登录用户。根据您共享的代码,看起来您没有将正确的参数传递到parse.user.login()方法。

登录()方法采用两个参数 - 第一个是用户名,第二个是密码。基于您的代码,看来您将输入字段的值(当前为空)作为用户名和密码作为第二个参数。

您需要更改代码,以使其通过两个参数将用户名和密码输入字段传递,例如:

Parse.User.logIn(usernameInput.value, passwordInput.value).then(function(user){
  alert(`Welcome ${user.get('username')}`);
  login.style.display='none';
  membersDiv.style.display='block';
  addMemberArea.style.display='block';
}).catch(function(error){
  alert(error);
})

有关使用Parse JavaScript SDK登录用户的更多信息,请在此处查看文档:

https://docs.parseplatform.org/js/guide/ugide/#logging-in

It looks like you're using the Parse JavaScript SDK to log in users. Based on the code you've shared, it looks like you're not passing the correct parameters to the Parse.User.logIn() method.

The logIn() method takes two parameters - the first is the username, and the second is the password. Based on your code, it looks like you're passing the value of the input field (which is currently empty) as the username, and the password as the second parameter.

You'll want to change your code so that it passes the username and password input fields as the two parameters, like so:

Parse.User.logIn(usernameInput.value, passwordInput.value).then(function(user){
  alert(`Welcome ${user.get('username')}`);
  login.style.display='none';
  membersDiv.style.display='block';
  addMemberArea.style.display='block';
}).catch(function(error){
  alert(error);
})

For more information on logging in users with the Parse JavaScript SDK, check out the documentation here:

https://docs.parseplatform.org/js/guide/#logging-in

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文