Authentication params for form GET calls
This commit is contained in:
@@ -20,9 +20,12 @@ export interface SignupForm {
|
||||
};
|
||||
}
|
||||
|
||||
export async function getForms(): Promise<SignupForm[]> {
|
||||
export async function getForms(auth = false): Promise<SignupForm[]> {
|
||||
try {
|
||||
const resp = await axios.get(url);
|
||||
const headers = auth ? { "Authorization": getAuthHeader() } : null;
|
||||
const resp = await axios.get(url, {
|
||||
headers
|
||||
});
|
||||
const { results } = resp.data;
|
||||
return results;
|
||||
} catch (err) {
|
||||
@@ -31,9 +34,12 @@ export async function getForms(): Promise<SignupForm[]> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getForm(id: number): Promise<SignupForm> {
|
||||
export async function getForm(id: number, auth = false): Promise<SignupForm> {
|
||||
try {
|
||||
const resp = await axios.get(`${url}${id}/`);
|
||||
const headers = auth ? { "Authorization": getAuthHeader() } : null;
|
||||
const resp = await axios.get(`${url}${id}/`, {
|
||||
headers
|
||||
});
|
||||
return resp.data;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
@@ -47,7 +47,7 @@ class AdminSignupPage extends React.Component<AdminSignupPageProps, AdminSignupP
|
||||
}
|
||||
|
||||
fetchSignupForms = async () => {
|
||||
const getSignupFormsPromise = getForms();
|
||||
const getSignupFormsPromise = getForms(true);
|
||||
try {
|
||||
const signupForms = await getSignupFormsPromise;
|
||||
this.setState({
|
||||
|
||||
@@ -84,7 +84,7 @@ class EventCreatePage extends React.Component<EventCreatePageProps, EventCreateP
|
||||
|
||||
fetchSignupForms = async () => {
|
||||
try {
|
||||
const signupForm = await getForms();
|
||||
const signupForm = await getForms(true);
|
||||
this.setState({
|
||||
signupForm
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user