我正在尝试显示来自此https://pomber.github.io/covid19/timeseries.json的 JSON 数据,但出现错误:
(ErrorException(code: 0): Undefined index: confirmed
我期望的是我可以显示国家名称列表以及日期、确认等。
这是我的看法:
@foreach($results as $json_d)
{{ $json_d['date'] }}
{{ $json_d['confirmed'] }}
{{ $json_d['deaths'] }}
{{ $json_d['recovered'] }}
@endforeach
这是我的控制器:
$client = new Client();
$request = $client->get('https://pomber.github.io/covid19/timeseries.json');
$response = $request->getBody()->getContents();
$results = json_decode($response, true);
return view('dashboard', compact('results'));
任何帮助,将不胜感激 :)
大话西游666
临摹微笑