This commit is contained in:
scammo
2021-08-18 22:59:44 +02:00
parent 513d204d58
commit f0ef4e7f13
7 changed files with 141 additions and 126 deletions

View File

@ -43,10 +43,11 @@
</div>
</template>
<script>
import axios from "axios";
import RequestMixin from "@/mixins/request.mixin"
export default {
name: "Index",
mixins: [RequestMixin],
data() {
return {
showErrorMessage: false,
@ -54,31 +55,5 @@ export default {
password: "",
};
},
methods: {
async submitLogin() {
this.showErrorMessage = false;
try {
const loginResult = await axios.post(
`${this.apiUrl}/users/login`,
{
username: this.username,
password: this.password,
}
);
if (loginResult.status === 200) {
this.showErrorMessage = false;
//success login
localStorage.setItem("token", loginResult.data.token);
localStorage.setItem("user_id", loginResult.data.user_id);
this.$router.push({ path: "/s/search" });
} else {
this.showErrorMessage = true;
}
} catch (error) {
console.error(error);
this.showErrorMessage = true;
}
},
},
};
</script>