SAS® af-axios
af-axios
is a library used by afcli
and Create SAS® App for handling and configuring axios
for App Factory Cloud.
Usage
import { useNavigate } from 'react-router';
import { MsalAuth } from '@sassoftware/af-axios/react';
import { MsalProvider } from '@azure/msal-react';
const Auth = ({ children }) => {
const navigate = useNavigate();
const navigationClient = new CustomNavigationClient(navigate);
msalInstance.setNavigationClient(navigationClient);
return (
<MsalProvider instance={msalInstance}>
<MsalAuth>{children}</MsalAuth>
</MsalProvider>
);
};
export default Auth;
You should be able to wrap your app (or specific routes) in Auth
component and use useAxios
hook to get an axios instance with Authorization header and 401 response handler.
For more information on how to provide msalInstance
and CustomNavigationClient
please see https://www.npmjs.com/package/@azure/msal-react
Local development
Running in a local project
- Run
npm run build:release
to create a build release - Run
npm pack
to create a TAR archive file (.tgz). You should see the name of newly created file at the end of the output. - Run
npm install [.tgz path]
. Make sure to replace [.tgz path]
with a correct local path of a file created by npm pack
command. - Run your project
Cleanup
Previous set of commands will create a lot of files in the root of the project.
To clean the files run git clean -d -f
. Note that this command will remove all untracked files so a good idea might be a dry run with git clean -d -n
before the actual cleanup.
Contributions
This project is currently intended for use by participants in the SAS Hackathon. During this event, the repository will refrain from accepting external contributions. However, we have plans to open source the project in the near future, at which point we will welcome contributions from the community.
Please note that after the SAS Hackathon concludes, this notice will be removed, and we will provide updated guidelines for contributing to the project once it becomes open source. We appreciate your understanding and look forward to collaborating with you in the future.