
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@acrool/react-fetcher
Advanced tools
Acrool React Fetcher is a solution for API integration and Auth state management in React projects. It helps you easily manage tokens, make API requests, perform GraphQL queries, and handle authentication flows.
A solution for API integration and token management in React projects
yarn add @acrool/react-fetcher
Add the following to your entry file (e.g. index.tsx):
import "@acrool/react-fetcher/dist/index.css";
Wrap your app with AuthStateProvider and AxiosClientProvider. It is recommended to use AppFetcherProvider to automatically wrap all necessary providers:
import AppFetcherProvider from '@/library/react-fetcher';
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<AppFetcherProvider>
<App />
</AppFetcherProvider>
);
For Redux Toolkit Query, create baseApi.ts:
import { createGraphQLFetcher } from '@acrool/react-fetcher';
import { createApi } from '@reduxjs/toolkit/query/react';
import { axiosInstance } from '@/library/react-fetcher';
export const baseApi = createApi({
reducerPath: 'api',
baseQuery: async (query, api, extraOptions) => {
// Token handling and refresh are managed automatically
const data = await createGraphQLFetcher(axiosInstance, query.document)(query.args);
return { data };
},
endpoints: () => ({}),
});
import { useAuthState } from '@acrool/react-fetcher';
const { getTokens, updateTokens } = useAuthState();
const { data, refetch } = useGetBookmarkQuery({ variables: { bookmarkId: '1' } });
const handleMockTokenInvalid = () => {
updateTokens(curr => ({
...curr,
accessToken: 'mock-invalid-token',
}));
refetch();
};
const login = useLogin();
const logout = useLogout();
await login({ variables: { input: { account, password } } });
logout();
(.net not support)
default: ?statusIds[]=1&statusIds[]=2
change to: ?statusIds=1&statusIds=2
export const baseQueryWithAxios: BaseQueryFn<IQuery> = async (query, BaseQueryApi, extraOptions) => {
await mutex.waitForUnlock();
try {
const {url, method, fetchOptions, ...args} = query;
const data = await createRestFulFetcher(axiosInstance, {url, method}, getContentTypeWithMethod)({
...args,
fetchOptions: {
...fetchOptions,
paramsSerializer: (params) => {
return qs.stringify(params, {indices: false});
}
}
});
return {
data,
meta: {}
};
} catch (error: any) {
dialog.error(error.message, {code: error.code});
return {
error: {
code: error.code || 500,
message: error.message
},
};
}
};
FAQs
Fetcher library based for Reactjs
The npm package @acrool/react-fetcher receives a total of 8 weekly downloads. As such, @acrool/react-fetcher popularity was classified as not popular.
We found that @acrool/react-fetcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.