Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/studio-home/data/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('studio-home api calls', () => {
});

it('should get studio v1 libraries data', async () => {
const apiLink = `${getApiBaseUrl()}/api/contentstore/v1/home/libraries`;
const apiLink = `${getApiBaseUrl()}/api/contentstore/v3/home/libraries/`;
axiosMock.onGet(apiLink).reply(200, generateGetStudioHomeLibrariesApiResponse());
const result = await getStudioHomeLibraries();
const expected = generateGetStudioHomeLibrariesApiResponse();
Expand Down
10 changes: 8 additions & 2 deletions src/studio-home/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { camelCaseObject, snakeCaseObject, getConfig } from '@edx/frontend-platf
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';

export const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;
export const getStudioHomeApiUrl = () => new URL('api/contentstore/v1/home', getApiBaseUrl()).href;
// FC-0118 (ADR 0028/0037): standardized v3 Studio Home endpoint. The trailing
// slash is required by the DRF DefaultRouter that serves the v3 `HomeViewSet`
// (the v1 route was a plain APIView). The aggregated home context lives at the
// `list` action `…/v3/home/`, and the library list at `…/v3/home/libraries/`.
export const getStudioHomeApiUrl = () => new URL('api/contentstore/v3/home/', getApiBaseUrl()).href;
export const getRequestCourseCreatorUrl = () => new URL('request_course_creator', getApiBaseUrl()).href;
export const getCourseNotificationUrl = (url) => new URL(url, getApiBaseUrl()).href;

Expand Down Expand Up @@ -55,7 +59,9 @@ export interface LibrariesV1ListData {
}

export async function getStudioHomeLibraries(): Promise<LibrariesV1ListData> {
const { data } = await getAuthenticatedHttpClient().get(`${getStudioHomeApiUrl()}/libraries`);
// `getStudioHomeApiUrl()` already ends in a slash (`…/v3/home/`); the v3
// library list is the `libraries` action at `…/v3/home/libraries/`.
const { data } = await getAuthenticatedHttpClient().get(`${getStudioHomeApiUrl()}libraries/`);
return camelCaseObject(data);
}

Expand Down