Best Way: ajax and route

Published 2 months ago by Boris56

Hi,

I would like to know what is the best way to use Laravel roads with ajax calls.

Use the classic "web.php" routes use by php app or create specific routes in "api.php"?

I am asking for safety and good practice.

Thank you.

Best Answer (As Selected By Boris56)
Snapey

if your user is authenticated then use web.php

BishoyWagih

if you are making an api so you have to use api.php file

else use web.php file..

Snapey
Snapey
2 months ago (992,285 XP)

if your user is authenticated then use web.php

Boris56

@Snapey Yes, is for use on admin panel, so use regular routes on web.php is better ?

Cronix
Cronix
2 months ago (726,250 XP)

Yes, unless you want to make it more complex and issue tokens and stuff...

Boris56

Thank you!

Please sign in or create an account to participate in this conversation.