In this video we are going to learn about the Http Client.
Http Client allowing you to quickly make outgoing HTTP requests.
to communicate with other web applications.
It makes easy to send HTTP requests with data, headers and trivial to integrate with web services.
Now lets see how can we make GET,Post,Put and Delete request using the http client.
So lets start First of all create a controller.
So go to the command prompt and here just type.

php artisan make:controller ClientController

Here I am going to use JSONPlaceholder.
JSONPlaceholder is a Fake Online REST API for Testing.
swtich to the browser and just search here.
Jsonplacehodler, Now click on jsonplaceholder link ok.
Lets use these routes okay.
Now, lets see the Get request first.
So go to the ClientController and Create a function here.
And get the url from json placeholder.
Just copy this url and paste here.


public function getAllPost()
{
$response= Http::get('https://jsonplaceholder.typicode.com/posts');
return $response->json();
}


And also import Http on top of the page.


use Illuminate\\Support\\Facades\\Http;


All right now create a route for this.
So goto the web.php file and here just create a new route.
So just type here.

Route::get('/posts',['ClientController::class, 'getAllPost']);

Now lets check.
Switch to the browser and here type /posts.
You can see here all the posts Now get individual post by their id.
For that just go to the Client Controller and here just.
Create another function.
So just type here.

public function PostById($id)
{
$post = Http::get('https://jsonplaceholder.typicode.com/posts/'.$id);
return $post;
}


Now crate route So open web.php file and here just ype.

Route::get('/post/{id}',[ClientController::class,'PostById']);

Alright, Now lets check.
So switch to the browser and here.
Just type in to the url.
/posts/1.
You can see here the post.
If I change the post id lets say post id is 4.
You can see the post by their id Now make post request.
So just create another method.

public function addPost()
{
$post = Http::post('https://jsonplaceholder.typicode.com/posts',[
'userId'=>1,
'title'=>'new post',
'body'=>'new post description'.
]);
return $post->json();
}


Now create route.

Route::get('/add-post',[ClientController::class, 'addPost');

Now lets check.
So switch to the browser and here just type.
/add-post.
You can see here a new post is added.
Now make a put request.
For that create another new function.

public function updatePost()
{
$response =Http::put('https://jsonplaceholder.typicode.com/posts/1',[
'title'=>'updated title',
'body'=>'updated description'.
]);
return $response->json();
}


Now create route for this.

Route::get('update-post',[ClientController::class,'updatePost');

Now lets check.
So just type here /update-post.
You can see here the post is updated.
Now make a delete request.
Just create an new function.

public function deletePost($id)
{
$response = Http::delete('https://jsonplaceholder.typicode.com/posts'.$id);
return $response->json();
}

Now create route.

Route::get('/delete-post/{id}',[ClientController::class,'deletePost']);

Now lets check.
Just type her delete-post/2.
You can see here the post has been deleted.
So in this way you can use Http Client in laravel 8 so that's all about Http Client in laravel 8.