【问题标题】:Laravel request using guzzle does not respond使用 guzzle 的 Laravel 请求没有响应
【发布时间】:2019-09-08 02:05:18
【问题描述】:

这很好用: screenshot insomnia

但是当我尝试通过 api 路由(POST http://127.0.0.1:8000/api/login 也使用 Insomnia)做同样的事情时,正确地导致了这个登录功能,我没有得到响应。我设置了超时来结束请求,否则它会在获取请求中保持“循环”。为什么这不起作用?

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

}

【问题讨论】:

标签: laravel-5 guzzle


【解决方案1】:

使用 php artisan serve 无法实现“嵌套请求”。我设法用 xampp/apache 运行这段代码。另见https://laracasts.com/discuss/channels/laravel/api-call-not-returning-a-response

【讨论】:

    猜你喜欢
    • 2018-08-04
    • 2018-12-22
    • 2020-07-14
    • 1970-01-01
    • 2019-12-17
    • 2020-08-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    相关资源
    最近更新 更多