fix crud users
This commit is contained in:
@@ -19,15 +19,24 @@ document.addEventListener("DOMContentLoaded", function (e) {
|
||||
submitButton.disabled = true;
|
||||
spinner.classList.remove("d-none");
|
||||
|
||||
let jsonData = {};
|
||||
formData.forEach((value, key) => {
|
||||
jsonData[key] = value;
|
||||
});
|
||||
|
||||
console.log(jsonData);
|
||||
|
||||
try {
|
||||
let response = await fetch(form.action, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
.getAttribute("content"),
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${document
|
||||
.querySelector('meta[name="api-token"]')
|
||||
.getAttribute("content")}`,
|
||||
},
|
||||
body: formData,
|
||||
body: JSON.stringify(jsonData),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
|
||||
@@ -8,8 +8,13 @@
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{{ route('users.index') }}" class="btn btn-sm btn-secondary me-2">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formCreateUsers" action="{{route('users.store')}}" method="POST">
|
||||
<form id="formCreateUsers" action="{{route('api.users.store')}}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="name">Name</label>
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{{ route('users.index') }}" class="btn btn-sm btn-secondary me-2">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formUpdateUsers" action="{{ route('users.update', $user->id)}}" method="post">
|
||||
@csrf
|
||||
|
||||
Reference in New Issue
Block a user