Laravel 5.6 with React.js & MySQL Tutorial: Episode 8 | Posting Data (Axios Post Request)




Check out my new React.js series: https://www.youtube.com/watch?list=PLTXFz3WKxvNKm0_IRoQY1VAapbO1gYktt&v=EHqBe3-Ilto.

Original source


7 responses to “Laravel 5.6 with React.js & MySQL Tutorial: Episode 8 | Posting Data (Axios Post Request)”

  1. In your BlogArticle component, the reason why your markup needs to be wrapped in an if statement is because the post attributes (name and body), are not defined until the AJAX request comes back with a valid response. Instead of returning null, what I like to do is to use a generic Loader component, so you can show some indication that the request is processing, a spinner for example.

  2. I have noticed that when you hit refresh after you navigate through your website , the Laravel throws an Exception : "Sorry, the page you are looking for could not be found." .
    Which is an expected behavior because that route doesn't exist in Laravel routes .
    To solve this i have create a single Laravel web route to assign the React Router.

    Please see bellow :
    Route::any('{all}', function () {
    return view('welcome');
    })->where(['all' => '.*']);

    where all requests pass through the welcome page , and when we realoding the welcome page the React Router kicks it and loads the page indicated to URL

    Have you find a better way to accomplish that ?

Leave a Reply