Add get request

This commit is contained in:
Adam Butterworth
2019-02-20 10:14:39 -05:00
committed by Adam Butterworth
parent c46d8506e4
commit 9585e0a1ef

View File

@@ -2,6 +2,8 @@ import { getAuthenticatedAPIClient } from '@edx/frontend-auth';
import { configuration } from '../config';
const lmsBaseUrl = process.env.LMS_BASE_URL;
const apiClient = getAuthenticatedAPIClient({
appBaseUrl: configuration.BASE_URL,
authBaseUrl: process.env.LMS_BASE_URL,
@@ -13,4 +15,20 @@ const apiClient = getAuthenticatedAPIClient({
csrfCookieName: configuration.CSRF_COOKIE_NAME,
});
export function getUserPreference(username, preferenceKey) {
const url = `${lmsBaseUrl}/api/user/v1/preferences/${username}/${preferenceKey}`;
return new Promise((resolve, reject) => {
apiClient.get(url)
.then((response) => {
resolve(response.data);
})
.catch((error) => {
reject(error);
});
});
}
export default apiClient;