Files
frontend-app-discussions/src/data/api.js
Adolfo R. Brandes 0c71e8b5b7 feat: Support runtime configuration (second attempt)
(This reintroduces the change in 9f84230c that was later reverted by
67b0b33a.)

frontend-platform supports runtime configuration since 2.5.0 (see the PR
that introduced it[1], but it requires MFE cooperation.  This implements
just that: by avoiding making configuration values constant, it should
now be possible to change them after initialization.

Almost all changes here relate to the `LMS_BASE_URL` setting, which in
most places was treated as a constant.

[1] https://github.com/openedx/frontend-platform/pull/335
2022-12-20 17:54:21 +05:00

20 lines
665 B
JavaScript

/* eslint-disable import/prefer-default-export */
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { getApiBaseUrl } from './constants';
export const getBlocksAPIURL = () => `${getApiBaseUrl()}/api/courses/v1/blocks/`;
export async function getCourseBlocks(courseId, username) {
const params = {
course_id: courseId,
username,
depth: 'all',
requested_fields: 'children,discussions_id',
block_types_filter: 'course,chapter,sequential,vertical,discussion',
student_view_data: 'discussion',
};
const { data } = await getAuthenticatedHttpClient()
.get(getBlocksAPIURL(), { params });
return data;
}