Skip to content

Commit

Permalink
fix: get the APIClient instance from the app instance
Browse files Browse the repository at this point in the history
  • Loading branch information
chenos committed Jun 19, 2024
1 parent 0e778e7 commit 2d2f1c8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/

import { useAPIClient } from '@nocobase/client';
import { useApp } from '@nocobase/client';
import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export const AuthProvider: React.FC = (props) => {
const location = useLocation();
const api = useAPIClient();
const app = useApp();

useEffect(() => {
const params = new URLSearchParams(location.search);
const authenticator = params.get('authenticator');
const token = params.get('token');
if (token) {
api.auth.setToken(token);
api.auth.setAuthenticator(authenticator);
app.apiClient.auth.setToken(token);
app.apiClient.auth.setAuthenticator(authenticator);
}
});
return <>{props.children}</>;
Expand Down

0 comments on commit 2d2f1c8

Please sign in to comment.