guzzlehttp同步请求永远不会解决或拒绝

时间:2019-04-09 09:42:59

标签: laravel asynchronous guzzlehttp

以下是我的代码:

    $client = new Client();
    $api = 'some api';
    $promise = $client->requestAsync(
        'POST',
        $api,
        [
            'form_params' => [
                'shares' => $shares->pluck('uuid')->implode(','),
                'bind_share' => $event->share->uuid
            ],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ]
    );

    $promise->then(
        function (ResponseInterface $response) {
            Log::info('Response Body:'.$response->getBody()->__toString());
            Log::info('Response status code:'.$response->getStatusCode());
        },
        function (RequestException $request) {
            Log::info('Request Exception:', $request->getTrace());
        }
    );

我的问题是: (1)请求服务器未收到请求 (2)承诺解决或拒绝从未执行

0 个答案:

没有答案