Skip to content

Commit adb16d9

Browse files
committedMar 15, 2022
Update phpGuzzle.js
Add wait to async call
1 parent 6b224ab commit adb16d9

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed
 

‎codegens/php-guzzle/lib/phpGuzzle.js

+4-20
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,11 @@ function getSnippetFooterSync (includeRequestOptions) {
171171
*/
172172
function getSnippetFooterAsync (includeRequestOptions) {
173173
if (!includeRequestOptions) {
174-
return '$promise = $client->sendAsync($request);\n' +
175-
'$promise->then(\n' +
176-
' function (ResponseInterface $res) {\n' +
177-
' echo $res->getBody();\n' +
178-
' },\n' +
179-
' function (RequestException $e) {\n' +
180-
' echo $e->getMessage();\n' +
181-
' echo $e->getRequest()->getMethod();\n' +
182-
' }\n' +
183-
');\n';
174+
return '$res = $client->sendAsync($request)->wait();\n' +
175+
'echo $res->getBody();\n';
184176
}
185-
return '$promise = $client->sendAsync($request, $options);\n' +
186-
'$promise->then(\n' +
187-
' function (ResponseInterface $res) {\n' +
188-
' echo $res->getBody();\n' +
189-
' },\n' +
190-
' function (RequestException $e) {\n' +
191-
' echo $e->getMessage();\n' +
192-
' echo $e->getRequest()->getMethod();\n' +
193-
' }\n' +
194-
');\n';
177+
return '$res = $client->sendAsync($request, $options)->wait();\n' +
178+
'echo $res->getBody();\n';
195179
}
196180

197181
/**

0 commit comments

Comments
 (0)
Please sign in to comment.