I use Laravel + Breeze + React. In default this stack using "post" from useform. Standard example:
const submit = (e) => {
e.preventDefault();
post(route('register'));
};
But sometimes I need to return value from backed (for example with stored object or true\false value). How can I display returning value from backend? .then(() => ...)
doesn;t work with post()
. Any idea?
That post
method is using Inertiajs.
You can use the onSuccess
handler to grab the response data:
post(route('register'), {
onSuccess: (data) => console.log(data),
})
Learn more here: https://inertiajs.com/forms