Ignore:
Timestamp:
01/25/25 00:58:19 (3 months ago)
Author:
Ljubomir Ilievski <ilievski.ljubomir@…>
Branches:
master
Children:
4894099
Parents:
a520992
Message:

Zavrsen pogolem del Login/Register Logika

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ReserveNGo-frontend/src/components/Project/register_.vue

    ra520992 r17bf12d  
    11<script>
    22
     3
     4import { userStore } from '@/PiniaStores/UserStore.js'
    35
    46export default {
     
    79      path: '',
    810      url: 'http://localhost:8080/api/auth/register/',
     11
    912      form_info:{
    1013        firstName: '',
     
    1518
    1619      },
    17       data: {}
     20     /* data: {
     21        id: 0,
     22        firstName: "",
     23        lastName: "",
     24        email: "",
     25        phoneNumber: "",
     26        role: "",
     27        token: ""
     28      },*/
     29      userStore_: userStore(),
     30
     31      //NE ZABORAVAJ TREBA DA SREDIS VCITUVANJE NA data od userStore na pocetok na stranicata
    1832
    1933    }
     
    2135
    2236  methods: {
    23     register() {
    24       fetch(this.url+this.path, {
     37   async register() {
     38     await fetch(this.wholeUrl, {
    2539        method: 'POST',
    26         headers: { "Content-Type": "application/json" },
    27         body: JSON.stringify({firstName: this.firstName, lastName: this.lastName, email: this.email, password: this.password})
    28       }).then((response) => {response.json()})
    29         .then((json) => this.data = json)
     40        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
     41        body: new URLSearchParams({
     42          firstName: this.form_info.firstName,
     43          lastName: this.form_info.lastName,
     44          email: this.form_info.email,
     45          password: this.form_info.password,
     46          phoneNumber: this.form_info.phoneNumber})
     47      }).then((response) => response.json())
     48        .then((json) => {this.userStore_.setLocalStorage(json)})
     49          //console.log("Data received:", this.data);
     50          //this.userStore_.setLocalStorage(json)
     51        //console.log(json)
    3052
     53     //console.log(this.userStore_.data)
    3154    }
    3255
    3356  },
    34   /*computed: {
    35     somevariabletest(){
     57  computed: {
     58    wholeUrl(){
    3659      return this.url+this.path;
     60    },
     61    testJson(){
     62      return JSON.stringify({
     63        firstName: this.form_info.firstName,
     64        lastName: this.form_info.lastName,
     65        email: this.form_info.email,
     66        password: this.form_info.password,
     67        phoneNumber: this.form_info.phoneNumber})
    3768    }
    38   }*/
     69  }
    3970
    4071
     
    4980    <div class="row justify-content-center">
    5081
     82<!--      <form @submit.prevent="register" method="POST">-->
     83<!--      <form v-bind:action="wholeUrl" method="POST">-->
    5184
    5285  <div class="col-3">
    53     <form @submit.prevent="register()" method="POST">
     86    <form @submit.prevent="register" method="POST">
    5487      <label for="name" class="form-label" >Name</label>
    55       <input v-model="form_info.firstName" type="text" id="name" name="firstName" class="form-control" placeholder="Name" required>
     88      <input v-model="this.form_info.firstName" type="text" id="name" name="firstName" class="form-control" placeholder="Name" required>
    5689
    5790      <label for="surname" class="form-label">Surname</label>
Note: See TracChangeset for help on using the changeset viewer.