Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
How can i fix to make Axios post working in React?

I have a code to do login task:

                onSubmit() {
                    this.$q.loading.show();
                    this.$axios.post("http://localhost/adminision/api/usermanager/login.php", 
                    {
                        language: "vi",
                        instituteid: this.$store.state.mainState.istituto,
                        username: this.username,
                        password: this.passwd
                    }).then((t => {
                        1 == t.data.success ? (this.$store.commit("mainState/setLoginData", t.data.token), this.$store.commit("mainState/setFirstName", t.data.firstName), this.$store.commit("mainState/setLastName", t.data.lastName), this.$store.commit("mainState/setMatrixID", "login"), this.$q.sessionStorage.set("token", t.data.token), this.$router.push({
                            path: "/dashboard"
                        })) : (this.$q.loading.hide(), this.validatormessage = "Username or password not valid", this.mostraerrori = !0)
                    })).catch((t => {
                        this.validatormessage = t.response.data.error.description, this.mostraerrori = !0
                    }))
                },

But when i click submit button, this.$axios.post runs, but nothing happens. No login.php appear in Network tab of Chrome browser, with no js error. I've set breakpoint in catch body but it is unreachable. So, please help, what can i do ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have syntax error in your code. Each line should have been ended with semicolon instead of comma or If you leave it javascript ASI will auto insert it:

onSubmit() {
  this.$q.loading.show();
  this.$axios.post("http://localhost/adminision/api/usermanager/login.php", {
    language: "vi",
    instituteid: this.$store.state.mainState.istituto,
    username: this.username,
    password: this.passwd
  }).then((t => {
    if (t.data.susccess === 1) {
      this.$store.commit("mainState/setLoginData", t.data.token);
      this.$store.commit("mainState/setFirstName", t.data.firstName);
      this.$store.commit("mainState/setLastName", t.data.lastName);
      this.$store.commit("mainState/setMatrixID", "login");
      this.$q.sessionStorage.set("token", t.data.token);
      this.$router.push({
        path: "/dashboard"
      })
    } else {
      this.$q.loading.hide();
      this.validatormessage = "Username or password not valid";
      this.mostraerrori = !0;
    }
  })).catch((t) => {
    this.validatormessage = t.response.data.error.description;
    this.mostraerrori = !0;
  })
},
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda