From e4bd1f7d50064a0f0d7c4ebb08bc4a83ad31f4fd Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 19 Aug 2019 20:22:00 +0800 Subject: [PATCH] [+] Fetch request --- src/components/login/login.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 54b92aa..7d578fa 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -1,4 +1,5 @@ import {Component, Vue} from 'vue-property-decorator'; +import Constants from '@/constants'; /** * This component handles user login, and obtains data from the server. @@ -12,10 +13,21 @@ export default class Login extends Vue public password: any = ''; /** - * On click + * On click, sends username and password to the server. */ public onLoginClick() { + // Call custom event + this.$emit('login:click', this.username, this.password); + // Fetch request TODO: Add username and password when the server is ready. + fetch(`${Constants.API_URL}/veracross/courses`).then(res => + { + // Get response body text + res.text().then(text => + { + }) + }) + .catch(alert); } }