guzzle laravel post request code example

Example 1: use guzzle http client laravel

public function putGuzzleRequest()

{

    $client = new \GuzzleHttp\Client();

    $url = "http://myexample.com/api/posts/1";

    $myBody['name'] = "Demo";

    $request = $client->put($url,  ['body'=>$myBody]);

    $response = $request->send();



    dd($response);

}

Example 2: laravel http client

use Illuminate\Support\Facades\Http;

$response = Http::get('http://test.com');

Example 3: post request data not getting from guzzle laravel

use Illuminate\Support\Facades\Http;

Http::fake();

$response = Http::post(...);