Level 29
for GuzzleHttp
$response = (new GuzzleHttp\Client)->post('your_url.com', [
"form_params" => [
"dataIndex" :"dataValue"
],
]);
$decoded = json_decode((string) $response->getBody(), true);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello guys
while adding every new recordin DB, i want to send api request .
it is possible whie the user create new record using form can send api request same time??
public function store(Request $request)
{
$org=$request->all();
$Org = Organization::create($org);
// here i want to send api request like this
$client = new \GuzzleHttp\Client(["base_uri" => "http://server.test"]);
$response = $client->post("/api/post", $Org );//it should also return (problem 1)
//redirect the normal
return redirect()->route('Orgs.index');
}
how can i mange both return for api and normal ??
Please or to participate in this conversation.