Guzzle: postAsync is not working with guzzle 6

Created on 13 Jul 2015  路  2Comments  路  Source: guzzle/guzzle

https://github.com/guzzle/guzzle/issues/new
How do I pass data with Guzzle 6.0 asynchronous post?

My code is
$client = new Client();
$request = $client->postAsync($url, [
'json' => [
'company_name' => 'update Name'
],
]);
but i am checking in terminal is not calling any type of request

Most helpful comment

If you use wait it ist async, Wait switches internaly to blocking requests.

All 2 comments

Async requests require that you either explicitly wait on them to complete, or that you tick an event loop until the request completes. What you are doing here is initiating a request but exiting the process before it completes. Also note that a response promise is returned, not a request.

$client = new Client();
$promise = $client->postAsync($url, ['json' => ['company_name' => 'update Name']]);
$response = $promise->wait();

If you use wait it ist async, Wait switches internaly to blocking requests.

Was this page helpful?
0 / 5 - 0 ratings