Add get request
This commit is contained in:
committed by
Adam Butterworth
parent
c46d8506e4
commit
9585e0a1ef
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user