Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inertia Plain Axios Request

Its a very normally requirement that a web page may have multiple API requests. I have been Inertia.js and this works very good but it lacks a very important feature to make plain XHR requests.

However Inertia.js provides Inertia.reload() but it some cases it's not very useful.

I am looking for something like Inertia::xhr() keeping in mind that I can still use Inertia.js interceptors like onStart, onFinish etc.

Anyone can help to achieve this?

like image 243
Jatin Thapar Avatar asked Nov 01 '25 21:11

Jatin Thapar


1 Answers

You can do plain XHR requests with Axios (which is already a dependency anyway), or alternatively use the native Fetch api.

From the docs:

Using Inertia to submit forms works great for the vast majority of situations. However, in the event that you need more fine-grain control over the form submission, there's nothing stopping you from making plain xhr or fetch requests instead. Using both approaches in the same application is totally fine!

See also here

like image 94
Shaya Ulman Avatar answered Nov 04 '25 07:11

Shaya Ulman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!