Javascript Parse.User.logIn被卡住了

Javascript Parse.User.logIn被卡住了,javascript,parse-platform,parse-server,Javascript,Parse Platform,Parse Server,我制作了一个用户登录功能: export const userLogin = (email, password) => (dispatch) => { console.log(email, password); dispatch({ type: actionTypes.AUTH_LOGIN_STARTED }); console.log("after dispatch"); Parse.User.logIn(email, password, { succe

我制作了一个用户登录功能:

export const userLogin = (email, password) => (dispatch) => {
    console.log(email, password);
  dispatch({ type: actionTypes.AUTH_LOGIN_STARTED });
  console.log("after dispatch");
  Parse.User.logIn(email, password, {
    success(user) {
        console.log("in success");
      dispatch({
        type: actionTypes.AUTH_LOGIN_SUCCESS,
        user: user.toJSON(),
      });
     window.location.replace('/');
    },
    error(user, error) {
        console.log("in error")
      console.log({ error });
      // The login failed. Check error to see why.
      dispatch({
        type: actionTypes.AUTH_LOGIN_ERROR,
        error,
      });
    },
  });
};
但在
Parse.User.logIn
之后,它总是会被卡住,不会成功或出错。我已经记录了电子邮件和密码,它们是正确的


那么,我在这里遗漏了什么呢?

Parse.User.Login
。您应该使用:

或者,如果您有足够的想象力,您可以使用新的
await
语法(我认为这有点简洁):


另外:再次检查错误时的参数。我怀疑它是否会返回任何用户对象(只是
错误
),好奇的是,您使用了第一个选项还是第二个选项@FaizanAhmad?我使用了第二个选项
Parse.User.logIn(email, password)
  .then((user) => {
    console.log("in success");
    dispatch({
      type: actionTypes.AUTH_LOGIN_SUCCESS,
      user: user.toJSON(),
    });
    window.location.replace('/');
  })
  .error((user, error) => {
    console.log("in error")
    console.log({ error });
    // The login failed. Check error to see why.
    dispatch({
      type: actionTypes.AUTH_LOGIN_ERROR,
      error,
    });
  });
export const userLogin = (email, password) => async (dispatch) => {
  console.log(email, password);
  dispatch({ type: actionTypes.AUTH_LOGIN_STARTED });
  console.log("after dispatch");

  try {
    const user = await Parse.User.logIn(email, password);
    console.log("in success");
    dispatch({
      type: actionTypes.AUTH_LOGIN_SUCCESS,
      user: user.toJSON(),
    });
    window.location.replace('/');
  } catch (error) {
    console.log("in error")
    console.log({ error });
    // The login failed. Check error to see why.
    dispatch({
      type: actionTypes.AUTH_LOGIN_ERROR,
      error,
    });
  }
};