Skip to content
Snippets Groups Projects
Commit d7d0233e authored by Kristiane Skogvang Kolshus's avatar Kristiane Skogvang Kolshus
Browse files

complete api requests for testing

parent fd2edc47
No related branches found
No related tags found
1 merge request!17complete api requests for testing
Pipeline #267985 passed
import axios from 'axios';
export const apiClient = axios.create({
baseURL: '/api',
baseURL: 'http://localhost:5173/api',
//TODO: set api URL
});
\ No newline at end of file
......@@ -8,6 +8,7 @@ export default {
//components: {Svg},
data() {
return {
username: '',
email: '',
password: '',
showPassword: false, // Add showPassword property
......@@ -17,8 +18,8 @@ export default {
methods: {
async handleSubmit() {
try {
await apiClient.post('/login', {
email: this.email,
await apiClient.post('/auth/login', {
username: this.username,
password: this.password
}).then(response => {
setToken(response.data.token); //TODO: check token name
......@@ -43,14 +44,19 @@ export default {
<h1 id="login">Login</h1>
<p> Sign in to your already existing account</p>
<div class="loginBox">
<label>Username</label> <br>
<input type="text" required v-model="username" placeholder="username"/> <br>
<!--
<label>Email</label> <br>
<input type="email" placeholder="JohnDoe@email.com" required v-model="email"/> <br>
-->
<label>Password</label> <br>
<input :type="showPassword ? 'text' : 'password'" required v-model="password"/>
<button type="button" class="showPasswordIcon" @click="togglePasswordVisibility">
<Svg v-if="showPassword" :name="'hide-password-icon'" />
<Svg v-else :name="'show-password-icon'" />
</button><br>
<label></label>{{errorMsg}}<br>
<router-link to="/signup" id="signUpLink">SIGNUP</router-link>
</div>
</div>
......
......@@ -6,9 +6,10 @@
name: 'Register',
data(){
return{
first_name:'',
last_name:'',
email:'',
username: '',
//first_name:'',
//last_name:'',
//email:'',
password:'',
password_confirm:'',
errorMsg: '', //TODO: display error to user
......@@ -18,10 +19,11 @@
async handleSubmit() {
//TODO: use interceptor to check matching password, send one password
try {
await apiClient.post('/api/auth/register', {
first_name: this.first_name,
last_name: this.last_name,
email: this.email,
await apiClient.post('/auth/register', {
//first_name: this.first_name,
//last_name: this.last_name,
//email: this.email,
username: this.username,
password: this.password
//password_confirm: this.password_confirm
}).then(response => {
......@@ -47,12 +49,17 @@
<h1 id="signup">Signup</h1>
<p> Create an account to get started!</p>
<div class="signupBox">
<label>First Name</label> <br>
<input type="text" required v-model="username" placeholder="username"/> <br>
<!--
<label>First Name</label> <br>
<input type="text" required v-model="first_name" placeholder="John"/> <br>
<label>Last Name</label> <br>
<input type="text" required v-model="last_name" placeholder="Doe"/> <br>
<label>Email</label> <br>
<input type="email" required v-model="email" placeholder="JohnDoe@email.com"/> <br>
-->
<label>Password</label> <br>
<input type="text" required v-model="password" /> <br>
<label>Confirm Password</label> <br>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment