leonvr
291
4
Laravel

API Call not returning a response

Posted 4 months ago by leonvr

This works fine: http://127.0.0.1:8000/api/all

//api.php:

Route::get('all', function () {
    return 'everybody may access this api route';
});

But when I call the same route from within another route, I never get a response, and it keeps spinning...

What am I doing wrong?

api.php:

Route::get('/test', '[email protected]');

//AuthController.php:

...
use GuzzleHttp\Client;

class AuthController extends Controller
{
    public function test(Request $request)
    {
        $client = new Client([
            'timeout'  => 8.0,
        ]);

        //return 'gets here ok1';
        $response = $client->get('http://127.0.0.1:8000/api/all');
        //return 'does NOT get here';
        //500 internal error, the timeout I set at above line, otherwise it keeps spinning
        return $response->getBody();
    }
}

So http://127.0.0.1:8000/api/test never gets back...

Please sign in or create an account to participate in this conversation.