WordPress at a glance
function is not described

WP_REST_Autosaves_Controller::get_item() public WP 5.0.0

Get the autosave, if the ID is valid.

{} It's a method of the class: WP_REST_Autosaves_Controller{}

No Hooks.

Return

WP_Post/WP_Error. Revision post object if ID is valid, WP_Error otherwise.

Usage

$WP_REST_Autosaves_Controller = new WP_REST_Autosaves_Controller();
$WP_REST_Autosaves_Controller->get_item( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 5.0.0 Introduced.

Code of WP_REST_Autosaves_Controller::get_item() WP 5.5.1

<?php
public function get_item( $request ) {
	$parent_id = (int) $request->get_param( 'parent' );

	if ( $parent_id <= 0 ) {
		return new WP_Error(
			'rest_post_invalid_id',
			__( 'Invalid post parent ID.' ),
			array( 'status' => 404 )
		);
	}

	$autosave = wp_get_post_autosave( $parent_id );

	if ( ! $autosave ) {
		return new WP_Error(
			'rest_post_no_autosave',
			__( 'There is no autosave revision for this post.' ),
			array( 'status' => 404 )
		);
	}

	$response = $this->prepare_item_for_response( $autosave, $request );
	return $response;
}