I installed a package (https://github.com/kirill-latish/laravel-newsapi).
And after setting everything up and also everything in the controller like so:
public function newsapi(){
$response = NewsAPI::topHeadlines()->get([
'country' => 'gb',
'category'=>'sports'
]);
return view('newsapi', compact('response'));
}
and then added into the view:
{{ $response }}
i'm getting a:
htmlspecialchars() expects parameter 1 to be string, object given
How can i work this? And also besides retrieving all the json, how can i display the things normally in a view? such as the title of the news article and url?
Thanks in advance for the help.
{{ }}in blade uses toecho(). so toecho()it should be a 'String'dd($response);beforereturnstatement to see how object's structure looks like (and what keys you need from there). Post structure here too if you have further doubts.