Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kakallatt's avatar

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!

0 likes
3 replies
Ashraam's avatar

Does this $response->throw(); tell you something more ?

kakallatt's avatar

It doesn't throw anything. Just a pending request :(. Here is the error I get from Ngnix error log:

2020/04/04 09:01:39 [error] 17576#0: *7 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /nova-vendor/order/are$
Ashraam's avatar

that's weird, don't know where the problem could be sorry :/ Sounds like a Nginx problem imo

Please or to participate in this conversation.