APIs Calling
Crema has some predefined hooks and functions to call the APIs without writing redundant code like sending tokens and other extra configurations in APIs.
const [
{apiData, loading, initialUrl},
{setData, setLoading, updateInitialUrl, setQueryParams, reCallAPI},
] = useGetDataApi('/dashboard/academy', {data: []}, {page: 1, perPage: 10});
const infoViewActionsContext = useInfoViewActionsContext();
postDataApi('/wall/posts', infoViewActionsContext, {
post,
})
.then((data) => {
// Do anything that you want here
infoViewActionsContext.showMessage('Post Created Successfully!');
})
.catch((error) => {
infoViewActionsContext.fetchError(error.message);
});
Last updated