Api 处理错误异常(E_通知)未定义的偏移量:0

Api 处理错误异常(E_通知)未定义的偏移量:0,api,laravel-5,guzzlehttp,Api,Laravel 5,Guzzlehttp,在JSON内部,但它继续向我显示错误消息 确保代码正常工作并显示JSON文件的全文 有没有类似的PHP-lavarel方法可以使用 用作arrylist或用于 获取响应中的元素 您的代码应该是 $client = new Client(); $request = $client->post('http://localhost:4567/user/login', [ 'headers' => ['Content-Type' => 'applicat

在JSON内部,但它继续向我显示错误消息 确保代码正常工作并显示JSON文件的全文 有没有类似的PHP-lavarel方法可以使用 用作arrylist或用于 获取响应中的元素


您的代码应该是

$client = new Client();
$request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
          ]);
$request= json_decode($request->getBody(), true);
return $request[0];

能否显示
$request
中的内容?像dd($request)或其他什么?认为你我用了var_dump()请把你的所有函数
$client = new Client();
$request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
          ]);
$request= json_decode($request->getBody(), true);
return $request[0];
use GuzzleHttp\Client;

$client = new Client();
    $request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
            ]);
 return $request->getBody();