$client = new Client(['base_uri' => env('BACKEND_IP') . '/api/', 'verify' => false]); try { $response = $client->request('get', 'get_unread_email', ['query' => ['token' => session('thai_email_token')]]); $jsonResponse = json_decode($response->getBody()->getContents(), true); $unreadEmail = $jsonResponse['data']; } catch (RequestException $exception) { $unreadEmail = 0; } // form_param $response = $client->request('POST', 'http://httpbin.org/post', [ 'form_params' => [ 'field_name' => 'abc', 'other_field' => '123', 'nested_field' => [ 'nested' => 'hello' ] ] ]); /***********************************************************************************************/ $client = new Client([ 'base_uri' => env('BACKEND_IP') . '/api/', 'verify' => false, 'headers' => [ 'Authorization' => 'Bearer '.\request()->session()->get('accessToken') ] ]); try { $response = $client->request('get', 'upgrade_loa_by_email'); $jsonResponse = json_decode($response->getBody()->getContents(), true); return response()->json($jsonResponse); } catch (ClientException $exception) { $upgradeEmail = $exception->getMessage(); return response()->json($upgradeEmail, 400); } /*************************************************************************************************/ //json $response = $client->request('PUT', '/put', ['json' => ['foo' => 'bar']]);