llms_rest_get_api_endpoint_data( string $endpoint, array $params = array() )

Get data from a WP Rest API endpoint.


Parameters Parameters

$endpoint

(string) (Required) API endpoint, eg "/llms/v1/courses".

$params

(array) (Optional) Query params to add to the request.

Default value: array()


Top ↑

Return Return

(array|WP_Error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/llms-rest-functions.php

function llms_rest_get_api_endpoint_data( $endpoint, $params = array() ) {

	$req = new WP_Rest_Request( 'GET', $endpoint );
	if ( $params ) {
		$req->set_query_params( $params );
	}

	$res    = rest_do_request( $req );
	$server = rest_get_server();
	$json   = wp_json_encode( $server->response_to_data( $res, false ) );

	return json_decode( $json, true );

}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.