diff --git a/src/studio-home/data/api.test.js b/src/studio-home/data/api.test.js index febc5d07e2..4f47c9df86 100644 --- a/src/studio-home/data/api.test.js +++ b/src/studio-home/data/api.test.js @@ -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(); diff --git a/src/studio-home/data/api.ts b/src/studio-home/data/api.ts index b9b43253d8..b1395e2282 100644 --- a/src/studio-home/data/api.ts +++ b/src/studio-home/data/api.ts @@ -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; @@ -55,7 +59,9 @@ export interface LibrariesV1ListData { } export async function getStudioHomeLibraries(): Promise { - 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); }