# learnpress/4.1.6.9.1/assets/src/apps/js/frontend/profile/statistic.js

LearnPress – WordPress LMS Plugin for Create and Sell Online Courses, version 4.1.6.9.1. 37 lines.

- Page: https://pluginprobe.com/plugins/learnpress/4.1.6.9.1/code/assets/src/apps/js/frontend/profile/statistic.js
- Raw: https://pluginprobe.com/plugins/learnpress/4.1.6.9.1/raw/assets/src/apps/js/frontend/profile/statistic.js
- Modified: 2022-08-04T04:28:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/learnpress/4.1.6.9.1/code/assets/src/apps/js/frontend/profile/statistic.js#L10-L20`.

```javascript
import { addQueryArgs } from '@wordpress/url';

// Rest API load content course progress - Nhamdv.
const courseStatistics = () => {
	const elements = document.querySelector( '.learn-press-profile-course__statistic' );

	if ( ! elements ) {
		return;
	}

	const getResponse = ( ele, dataset ) => {
		wp.apiFetch( {
			path: addQueryArgs( 'lp/v1/profile/statistic', dataset ),
			method: 'GET',
		} ).then( ( response ) => {
			if ( response.status === 'success' && response.data ) {
				ele.innerHTML = response.data;
			} else {
				ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
			}
		} ).catch( ( err ) => {
			console.log( err );
			//ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ err.message && err.message }</div>`;
		} );
	};

	const elArgStatistic = document.querySelector( '[name="args_query_user_courses_statistic"]' );
	if ( ! elArgStatistic ) {
		return;
	}

	const data = JSON.parse( elArgStatistic.value );

	getResponse( elements, data );
};
export default courseStatistics;

```
