Issue logging in a user using Vue 3

I am developing a new app in Vue 3 and I am getting a 401 error when trying to post to my backendless app (trying to login a user). It also results in an error regarding the user’s email/password. I didnt have any issues with Vue 2.x however.

import Backendless from "@/plugins/backendless.js";
import { ref } from "vue";

export default {
  setup() {
    const email = ref(" ");
    const password = ref("");
    const Login = () => {
      const stayLoggedIn = true;
      console.log(email);
      Backendless.UserService.login(
        email.value,
        password.value,
        stayLoggedIn
      ).then(
        // eslint-disable-next-line no-unused-vars
        (user) => {
          localStorage.setItem("LoggedUser", true);
          Backendless.UserService.getCurrentUser()
            .then((user) => {
              if (user["role"] === "test") {
                this.$router.push({ path: "/test" });
              } else if (user["role"] === "two") {
                this.$router.push({ path: "/two" });
              } else if (user["role"] === "three") {
                this.$router.push({ path: "/four" });
              }
            })
            .catch((error) => {
              console.log(error);
            });
        }
      );
    };
    return {
      email,
      password,
      Login,
    };
  },```

I set up a plugin to be included in my Vue instance:

import Backendless from “backendless”;

const APP_ID = “27C8E9A7-EEAF-31D3-FFD0-B8C10AD39300”;
const API_KEY = “xxxxx-xxxxx-xxxxxxx-xxxxx”;
Backendless.initApp(APP_ID, API_KEY);

export default Backendless;

Have I missed something particular to create this issue?

Hi Louis,

Do you have the exact error message you’re getting?

Mark

Sorry about that, I do indeed:

Looks like the credentials are not valid. Could you try logging in with the same credentials here?:

That will use the same login API as you have in your app, you can check in the Network tab in the browser the API payload sent by console.

Regards,
Mark

Thank you for the quick response. I created a quick userin the backend and I am getting an invalid email/password when trying to login to that user using the REST console. I don’t believe I have ever experienced this in the past.

Could you please let me know test user credentials and I will be happy to try it in your app as well.

I noticed in your app the name column is marked as identity:

This means in the login API the value of the name column should be used as the login argument.