我在通过 HTTP 客户端发送 API 请求时遇到问题。我收到一个待处理的请求。如何完成响应并从中获取响应数据$response->collect()
这是我的代码:
public function postMultipleFiles($url, $files, $params)
{
$response = Http::withHeaders([
'Authorization' => auth()->check() ? 'Bearer '.auth()->user()->api_token:''
]);
foreach($files as $k => $file)
{
$response = $response->attach('images['.$k.']', $file);
}
$response->post($this->base_url.$url, $params);
return response()->json($response->collect());
}
我得到的错误
message: "Method Illuminate\\Http\\Client\\PendingRequest::collect does not exist."