function pp_check_reactapp_ajax() {
$request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
$request->set_header( 'content-type', 'application/json' );
$request->set_body( '{
"title": "'. $_POST['title'] .'"
}');
$response = rest_do_request( $request );
$server = rest_get_server();
$data = $server->response_to_data( $response, false );
if($data['id']){
echo '{"success": '. json_encode($data) .'}';
} else {
echo '{"error": "'. $data['message'] .'"}';
}
wp_die();
}
add_action( 'wp_ajax_nopriv_pp_check_reactapp_ajax', 'pp_check_reactapp_ajax' );
add_action( 'wp_ajax_pp_check_reactapp_ajax', 'pp_check_reactapp_ajax' );