admin管理员组文章数量:1297125
I'm making a call to an internal endpoint in order to try and speed up a task.
I don't need to wait for the task (that awaits at that endpoint) to complete for my script to move on, but it's still waiting to finish. I'm using the following:
$argsForRequest = array(
'agency_code' => '1234',
'another_param_here' => $myVar,
'timeout' => 0.01,
'blocking' => false,
'sslverify' => false,
);
$request = new WP_REST_Request( 'POST', '/my/custom/endpoint' );
$request->set_query_params( $argsForRequest );
$response = rest_do_request( $request );
Any idea on what I could be doing wrong?
Thanks!
I'm making a call to an internal endpoint in order to try and speed up a task.
I don't need to wait for the task (that awaits at that endpoint) to complete for my script to move on, but it's still waiting to finish. I'm using the following:
$argsForRequest = array(
'agency_code' => '1234',
'another_param_here' => $myVar,
'timeout' => 0.01,
'blocking' => false,
'sslverify' => false,
);
$request = new WP_REST_Request( 'POST', '/my/custom/endpoint' );
$request->set_query_params( $argsForRequest );
$response = rest_do_request( $request );
Any idea on what I could be doing wrong?
Thanks!
Share Improve this question asked Oct 25, 2020 at 18:23 Best Dev TutorialsBest Dev Tutorials 4451 gold badge7 silver badges21 bronze badges 3- Hi, did you find the solution ? – Gnanasekaran Loganathan Commented Mar 24, 2021 at 21:03
- @GnanasekaranLoganathan Yup I posted my solution. – Best Dev Tutorials Commented Mar 29, 2021 at 20:12
- Thank you for sharing the solution. – Gnanasekaran Loganathan Commented Mar 29, 2021 at 20:20
1 Answer
Reset to default 1rest_do_request
does not make a HTTP request to the REST API. rest_do_request
handles a request object directly. WP_REST_Request
and rest_do_request
are for handling requests, not making them. This is why your attempt to make it non-blocking failed.
If you want to make a non-blocking request to the REST API, you have to make a HTTP request using wp_remote_post
to the desired endpoint.
本文标签: Making internal rest requests nonblocking
版权声明:本文标题:Making internal rest requests non-blocking? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741648327a2390322.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论