Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(res => {
const normalizedData = camelcaseKeys(res.data);
dispatch(createRoleSuccess(normalizedData));
return normalizedData;
})
.catch(e => defaultErrorHandler(e, dispatch, createRoleFailure));
} = await axios.post(AUTH_URL, stringify(data), {
headers: {
'X-Client-Hash': md5(moment().format() + HASH_SECRET),
'X-Client-Time': moment().format(),
},
transformResponse: [
rowData => {
try {
return JSON.parse(rowData)
} catch (error) {
return rowData
}
},
],
})
return camelcaseKeys(response, { deep: true })
}
return401OnUnauthorizedError(async (req: Request, res: Response) => {
const { user_id: userId } = req.user;
const study = camelcaseKeys(req.body as Study);
const { studyId } = req.params;
if (!(await userIdIsAdminOfStudy(DbPool, studyId, userId))) {
throw new UnauthorizedError(req.route, userId);
return;
}
const { surveys, surveyors } = study;
const updatedStudy = await updateStudy(DbPool, { ...study, userId });
await Promise.all(surveyors.map(s => giveUserStudyAccess(DbPool, s, studyId)));
if (surveys) {
await Promise.all(
surveys.map(s => updateSurvey(DbPool, camelcaseKeys({ studyId, ...s })))
);
}
res.status(200).send();
})
)
success: prevState => ({
...prevState,
isLoading: false,
totalCount: action.payload.total_count,
totalPages: action.payload.total_pages,
currentPage: action.payload.current_page,
perPage: action.payload.per_page,
took: action.payload.took,
query: action.payload.query,
entities: camelcaseKeys(action.payload.results || {}, { deep: true }),
}),
});
export async function selectNewStudy(study: any) {
applicationState.currentStudy = study;
try {
applicationState.currentStudy.datapoints = camelcaseKeys(
await getRest(`/api/studies/${study.studyId}/datapoints`)
);
} catch (error) {
setSnackBar('error', `Unable to get study datapoints!`);
throw error;
}
}
.then(response => {
const normalizedData = camelcaseKeys(response.data);
dispatch(fetchVersionSuccess(normalizedData));
return normalizedData;
})
.catch(e => defaultErrorHandler(e, dispatch, fetchVersionFailure));
.then(res => {
const normalizedData = camelcaseKeys(res.data);
const actionPayload = { isGuest: false, data: normalizedData };
dispatch(userLoginSuccess(actionPayload));
return normalizedData;
})
.catch(e => defaultErrorHandler(e, dispatch, userLoginFailure));
success: prevState => ({
...prevState,
results: {
...state.results,
[action.meta.query]: camelcaseKeys(action.payload || {}, {
deep: true,
}),
},
}),
});
options = options || {}
if (options.data) {
options.method = 'post'
options.headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
options.data = stringify(decamelizeKeys(options.data))
}
if (options.params) {
options.params = decamelizeKeys(options.params)
}
const { data } = await instance(target, options as AxiosRequestConfig)
this.nextUrl = data && data.next_url ? data.next_url : null
return this.camelcaseKeys ? camelcaseKeys(data, { deep: true }) : data
}
}
success: prevState => ({
...prevState,
entities: {
...prevState.entities,
...keyBy(
camelcaseKeys(action.payload.chapters || {}, { deep: true }),
'id'
),
},
}),
});