Does this $response->throw(); tell you something more ?
Apr 3, 2020
3
Level 4
Laravel API: Request is not finished yet
This is my first time to create an API in Laravel. I created 2 laravel apps in my Valet server (1st app is API and 2nd is the consumer).
Here is the code for API:
api.php
<?php
use Illuminate\Support\Facades\Route;
Route::get('areas/provinces', 'Api\AreasController@getProvinces');
I just return a random data in AreasController
/**
* Get all provinces.
*
*/
public function getProvinces()
{
return response()->json(['something'=> []]);
}
The consumer code:
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Http;
use GuzzleHttp\Client;
Route::get('/', function () {
$response = Http::get('http://api.test/api/areas/provinces');
return $response->json();
});
It was just loading forever. When I checked in the Chrome developer tool, it said "Request is not finished yet". I did try to use GuzzleHttp library instead of Http Client of Laravel 7, but it didn't work either. However when I test with curl or Postman, it works well.
Thank you!
Please or to participate in this conversation.