Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
 
 
 
 
 
 

43 строки
884 B

  1. <template>
  2. <section class="shadowbox">
  3. <h2>Register</h2>
  4. <account v-if="!step" :err="err" @submit="create" />
  5. <billing v-if="step" :err="err" @submit="create" />
  6. </section>
  7. </template>
  8. <script setup>
  9. import { ref } from "vue"
  10. import Account from "./account.vue"
  11. import Billing from "./billing.vue"
  12. let err = ref("")
  13. const step = ref(0)
  14. function create(user) {
  15. console.log(user)
  16. fetch(`/api/user`,
  17. {method: 'POST',
  18. body: JSON.stringify(user),
  19. headers: {
  20. "Accept": "application/json",
  21. },
  22. }).then(resp => {
  23. console.log(resp)
  24. if (resp.ok) {
  25. return resp.json().then(u => { err.value = "" })
  26. } else {
  27. resp.text().then( e => err.value = e)
  28. }
  29. }).then(u => console.log(u))
  30. }
  31. </script>
  32. <style scoped>
  33. section {
  34. max-width: 400px;
  35. margin: auto;
  36. }
  37. </style>