In WordPress, is there an action hook or anything which allows you to run a callback after the response to a custom REST API endpoint, registered via
register_rest_route(), has been sent to the client? Ideally with the data of the request payload?
The closest thing we could find so far is the
rest_post_dispatch hook, which however still happens before the response is sent to the client.
Context: The reason why we have to do this is to execute multiple API calls after a successful REST API call, whose completion is irrelevant for the response delivered to the client. Hence to avoid that the request processing time appears to be much longer than it needs to be, as these other API requests can take up to multiple seconds to be fully processed.