Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!