You need to use HttpClient to call external API from laravel. For more information you can check here https://laravel.com/docs/10.x/http-client or https://laravel.com/docs/10.x/http-client#making-requests
Sep 25, 2023
6
Level 1
How to fetch data from api in laravel?
can anyone please tell me how to fetch data from api in laravel?
Level 50
Level 1
@shariff the page is loading and loading. nothing happens
Level 50
@shaonlimit May be you have internet issue. I can able to view the documentation https://laravel.com/docs/10.x/http-client.
I can provide some examples from the documentation. examples
use Illuminate\Support\Facades\Http;
$response = Http::get('http://example.com');
$response->body() : string;
$response->json($key = null, $default = null) : array|mixed;
$response->object() : object;
$response->collect($key = null) : Illuminate\Support\Collection;
$response->status() : int;
$response->successful() : bool;
$response->redirect(): bool;
$response->failed() : bool;
$response->clientError() : bool;
$response->header($header) : string;
$response->headers() : array;
Level 1
@shariff no the laravel blade file is loading and loading where the data will be showed
Level 50
Can you show some code? what issue you are facing?
Level 1
@shariff i can't provide code because this is the first day i am using laracast.
Please or to participate in this conversation.