Laravel使用枪口的请求不响应

时间:2019-04-17 18:42:52

标签: laravel-5 guzzle

这很好用: screenshot insomnia

但是,当我尝试通过api路由(也使用Insomnia的POST http://127.0.0.1:8000/api/login)执行相同的操作时,正确地导致了此登录功能,但没有得到响应。我将超时设置为结束请求,否则它将在get-request中保持“循环”。为什么这行不通?

<?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 个答案:

答案 0 :(得分:0)

“嵌套请求”无法通过php artisan服务使用。我设法用xampp / apache运行此代码。另请参见https://laracasts.com/discuss/channels/laravel/api-call-not-returning-a-response