UnFukWitAble
1 year ago

Where do AXIOS routes go?

Posted 1 year ago by UnFukWitAble

P.S. I am also using Passport. Not sure if it makes a difference.

Typically when you submit a form the old fashion way, you would add it to web.php and that route would result in a redirect with either errors a success flash message in the session.

Axios is expecting a response message not a redirect. Should I just change the Controller for the route to not redirect and keep it in web.php?

Or should I create a new Controller under app/Http/Controllers/API for example, that is used in routes/api.php?

What is typically the best practice here? Is there any examples anywhere of what a typical API controller would look like? That sends back error messages in error.data?

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