Here is an example of my API call:
this.$http.post("{{ route('shop.checkout.save-order') }}", {'_token': "{{ csrf_token() }}"})
.then(function (response) {
if (response.data.success) {
if (response.data.redirect_url) {
window.location.href = response.data.redirect_url;
} else {
window.location.href = "{{ route('shop.checkout.success') }}";
}
}
})
Now, I am looking to create an input field like this:
<input type="text" name="delivery_time" value="insert delivery time">
I want to send the value of this input to the API and retrieve it using the request()
helper in Laravel. Here is what I have tried so far:
let formData = new FormData(document.getElementById("delivery_time"));
this.$http.post("{{ route('shop.checkout.save-order') }}", {'test':formData,'_token': "{{ csrf_token() }}"})
However, this approach does not seem to be sending the data to the API. Any help would be appreciated. Thank you.