title: Show image from API in laravel
body: <p>I want to show an image from API using laravel, I already get the image URL from response, but when I want to show it to the data table, the image URL keeps the base URL and I don't want that</p>
  <p><strong>Controller</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use GuzzleHttp\Client;
  use Illuminate\Support\Facades\Config;
  use Session;
  
  class VehicleController extends Controller
  {
      public function index(){
          return view('pages/vehicle', [
              &quot;title&quot; =&gt; &quot;Vehicle&quot;
          ]);
      }
  
      public function getCategory() {
          $client = new Client();
          $response = $client-&gt;request(
              'GET',
              Config::get('constants.API_URL').Config::get('constants.vehicle').'/category',
              ['headers' =&gt; 
                  [
                      'Accept' =&gt; 'aplication/json',
                  ]
              ]
          )-&gt;getBody()-&gt;getContents();
                      
          return json_decode($response)-&gt;data;
      }
  
      public function getVehicles(){
          $client = new Client();
          $user = Session::get('sessionuser');
          $response = $client-&gt;request(
              'GET',
              Config::get('constants.API_URL').Config::get('constants.vehicle'),
              ['headers' =&gt; 
                  [
                      'Accept' =&gt; 'aplication/json',
                      'Authorization' =&gt; $user-&gt;token
                  ]
              ]
          )-&gt;getBody()-&gt;getContents();
          return json_decode($response)-&gt;data;
      }
  
  }
  </code></pre>
  <p><strong>Route</strong></p>
  <pre><code>Route::get('/category', [VehicleController::class, 'getCategory'])-&gt;name('vehicle.category');
  Route::get('/listvehicle', [VehicleController::class, 'getVehicles']);
  </code></pre>
  <p><strong>DataTable</strong></p>
  <pre><code>const getVehicleData = () =&gt; { 
      tableCategory = $('#table-kendaraan').DataTable({
          destroy: true,
          ajax: {
              url: `${base_url}/listvehicle`,
              dataSrc: '',
              type: 'GET',
              error: function(response) {
                  toastr.error('Error get data : ' + response.statusText)
              }
          },
          columns: [
              {
                  data: function (data, type, row, meta) {
                      return meta.row + meta.settings._iDisplayStart + 1;
                  },
              },
              {
                  &quot;render&quot;: function (data, type, JsonResultRow, meta) {
                      return '&lt;img src=&quot;'+JsonResultRow.qr_code+'&quot;&gt;';
                  }
              },
              { data: 'name' },
              { data: 'm_transport_categories.type' },
  
          ]
      })
  }
  </code></pre>
  <p>the variable <code>$base_url</code> is variable that getting the base URL which is localhost.</p>
  <p>The URL of image keeps returning the localhost URL like this</p>
  <p><a href="https://i.stack.imgur.com/rY3td.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rY3td.png" alt="enter image description here" /></a></p>
  <p>so it should be returning the base URL from API, how to do that?</p>
  <p>Nb : I already get the response directly from JS not using controller, but the URL of image show something like this <em>localhosturl/baseapiurl/uploads...</em> and I'm running this project using PHP artisan serve</p>