1
votes

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);
    }

}
1
Have you tried just /api/all instead?thisiskelvin
Just /api/all results in an error that the url is not properly formatted: cURL error 3: <url> malformed (see curl.haxx.se/libcurl/c/libcurl-errors.html)leonvr
anyone? I am not getting this solved...leonvr

1 Answers

2
votes

'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