Files
frontend-app-authn/src/register/data/service.js
Adeel Khan 6c9c5de11f Removes option call from multiple end points
This patch removes option call not needed
in certain end points via not sending
csrf token.

VAN-370
2021-02-19 19:55:06 +05:00

45 lines
1.1 KiB
JavaScript

import { getConfig } from '@edx/frontend-platform';
import { getHttpClient } from '@edx/frontend-platform/auth';
import querystring from 'querystring';
export async function registerRequest(registrationInformation) {
const requestConfig = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
const { data } = await getHttpClient()
.post(
`${getConfig().LMS_BASE_URL}/user_api/v2/account/registration/`,
querystring.stringify(registrationInformation),
requestConfig,
)
.catch((e) => {
throw (e);
});
return {
redirectUrl: data.redirect_url || `${getConfig().LMS_BASE_URL}/dashboard`,
success: data.success || false,
};
}
export async function getFieldsValidations(formPayload) {
const requestConfig = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
const { data } = await getHttpClient()
.post(
`${getConfig().LMS_BASE_URL}/api/user/v1/validation/registration`,
querystring.stringify(formPayload),
requestConfig,
)
.catch((e) => {
throw (e);
});
return {
fieldValidations: data,
};
}