title: Laravel Blade-View: Handling with Api Repsonse
body: <p>Let's say I have a simple blade view form with only one input field and a submit button. In this field you just have to write a name. After that you need to click the submit button which makes an api call.  </p>
  
  <p>To simplify let's say the api call is method:post and the url:'api/user'</p>
  
  <p>The calling api creates a new user in the db and responses with an json: </p>
  
  <pre><code>{
      "id": 1,
      "name": "Im a new user",
      "created_at": 20190119
  } 
  </code></pre>
  
  <p>As I know if I implement my blade.view like below:</p>
  
  <pre><code>&lt;form method="POST" action="/api/user"&gt;
      @csrf
      &lt;div class="form-group row"&gt;
          &lt;label for="username"
                 class="col-md-4 col-form-label text-md-right"&gt;{{ __('Name') }}&lt;/label&gt;
  
          &lt;div class="col-md-6"&gt;
              &lt;input id="username" type="text"
                     class="form-control"
                     name="username" value="{{ old('username') }}" required autofocus&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group row mb-0"&gt;
          &lt;div class="col-md-8 offset-md-4"&gt;
              &lt;button type="submit" class="btn btn-primary"&gt;
                  {{ __('Create') }}
              &lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My Page displays the response.
  What I want is to stay at the actual view and show the response as a alert e.g. $name . ' has has been created'</p>
  
  <p>Api route (routes/api.php):</p>
  
  <pre><code>Route::post('/user', 'UserController@createUser');
  </code></pre>
  
  <p>Route config (routes/web.php):</p>
  
  <pre><code>Route::get('/user' , function () {
  return view('user/create-user');
  });
  </code></pre>
  
  <p>Solutions that I know could work </p>
  
  <ul>
  <li><p>redirect to the same page (this means rerender the same page again and this is not really responsible - this solution leads to load the entire page again)</p></li>
  <li><p>return the same view in the UserController@createUser method with data (same as above and as far as I know an api call should response with a json and not with a view)</p></li>
  </ul>
  
  <p>Also I could use Ajax via  e.g. JQuery. As you can see there are bunch of solutions but which ones are the best. </p>
  
  <p>Can you say in that case there are best practices?</p>
  
  <p>Are there good solutions that laravel brings out of the box?</p>