leonvr
leonvr

Reputation: 113

Laravel request using guzzle does not respond

This works fine: screenshot insomnia

But when I try to do the same thing through an api route(POST http://127.0.0.1:8000/api/login also using Insomnia), which correctly leads to this login-function, I do not get a response. I set the timeout to end the request, otherwise it keeps 'looping' in the get-request. Why doesn't this work?

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use GuzzleHttp\Client;

class AuthController extends Controller
{
    public function login(Request $request)
    {
        $client = new Client([
            'timeout'  => 8.0,
        ]);
        $response = $client->get('http://127.0.0.1:8000/api/all');

        return response()->json($response);
    }

}

Upvotes: 1

Views: 1741

Answers (1)

leonvr
leonvr

Reputation: 113

'nested requests' are not possible using php artisan serve. I manage to run this code with xampp/apache. See also https://laracasts.com/discuss/channels/laravel/api-call-not-returning-a-response

Upvotes: 2

Related Questions