PHP Classes

File: resources/assets/js/views/Register.vue

Recommend this page to a friend!
  Classes of Hillary Kollan   Laravel eCommerce with Vue.js   resources/assets/js/views/Register.vue   Download  
File: resources/assets/js/views/Register.vue
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Laravel eCommerce with Vue.js
Implementation of an interactive eCommerce site
Author: By
Last change:
Date: 2 years ago
Size: 4,326 bytes
 

Contents

Class file image Download
<template> <div class="container"> <div class="row justify-content-center"> <div class="col-md-8"> <div class="card card-default"> <div class="card-header">Register</div> <div class="card-body"> <form> <div class="form-group row"> <label for="name" class="col-md-4 col-form-label text-md-right">Name</label> <div class="col-md-6"> <input id="name" type="text" class="form-control" v-model="name" required autofocus> </div> </div> <div class="form-group row"> <label for="email" class="col-md-4 col-form-label text-md-right">E-Mail Address</label> <div class="col-md-6"> <input id="email" type="email" class="form-control" v-model="email" required> </div> </div> <div class="form-group row"> <label for="password" class="col-md-4 col-form-label text-md-right">Password</label> <div class="col-md-6"> <input id="password" type="password" class="form-control" v-model="password" required> </div> </div> <div class="form-group row"> <label for="password-confirm" class="col-md-4 col-form-label text-md-right">Confirm Password</label> <div class="col-md-6"> <input id="password-confirm" type="password" class="form-control" v-model="password_confirmation" required> </div> </div> <div class="form-group row mb-0"> <div class="col-md-6 offset-md-4"> <button type="submit" class="btn btn-primary" @click="handleSubmit"> Register </button> </div> </div> </form> </div> </div> </div> </div> </div> </template> <script> export default { props : ['nextUrl'], data(){ return { name : "", email : "", password : "", password_confirmation : "" } }, methods : { handleSubmit(e) { e.preventDefault() if (this.password !== this.password_confirmation || this.password.length <= 0) { this.password = "" this.password_confirmation = "" return alert('Passwords do not match') } data = { "name": this.name, "email": this.email, "password": this.password, "c_password": this.password_confirmation }; let headers = { "Content-Type": "application/json", }; fetch('api/register', { method:"POST", body: JSON.stringify(data), headers: headers }).then(response => response.json()).then(response => { console.log(response); let data = response; localStorage.setItem('sellify.user', JSON.stringify(data.user)) localStorage.setItem('sellify.jwt', data.token) if (localStorage.getItem('sellify.jwt') != null) { this.$emit('loggedIn'); let nextUrl = this.$route.params.nextUrl; this.$router.push((nextUrl != null ? nextUrl : '/')) } }) } } } </script>