Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api-axios | Interceptor not working after upgrade #601

Open
Viou opened this issue Oct 26, 2023 · 0 comments
Open

api-axios | Interceptor not working after upgrade #601

Viou opened this issue Oct 26, 2023 · 0 comments

Comments

@Viou
Copy link

Viou commented Oct 26, 2023

Making the following updates:

"@availity/api-axios": "^7.3.1",
"@availity/api-axios": "^8.0.3",

"axios": "^0.27.2",
"axios": "^1.5.1",

I noticed that interceptors that I defined on the global axios version no longer hook into calls made through instances of AvApi.

Example interceptor:
return axios.interceptors.response.use(
response => {
const statusCode = response.status;
if (Math.floor(statusCode / 100) === 2) {
// logAPIMessages(response, apiStatuses.SUCCESS);
} else {
logAPIMessages(response, apiStatuses.ERROR);
}
return response;
},
error => {
// Server responded
return error.response;
}
);

Example AvApi:

const someEndpoint = new AvApi({
path: '/api/internal',
name: 'someEndpoint'
});

After some debugging, a workaround was discovered - add axios to each AvApi instantiation

const someEndpoint = new AvApi({
path: '/api/internal',
name: 'someEndpoint',
http: axios,
});

This workaround isn't ideal though, so noting in this issue in the hopes that a future version can fix this to make upgrades easier.

Note: adding a resolution did not resolve either:

"resolutions": {
"axios": "^1.5.1"
},

Your environment

"dependencies": {
"@availity/api-axios": "^8.0.3",
"@availity/date": "^4.2.4",
"@availity/env-var": "^2.0.2",
"@availity/feedback": "^7.1.2",
"@availity/form": "^1.7.2",
"@availity/help": "^2.2.0",
"@availity/localstorage-core": "^3.0.0",
"@availity/native-form": "^5.0.2",
"@availity/select": "^3.4.0",
"@availity/typography": "^1.5.0",
"@availity/yup": "5.1.2",
"availity-uikit": "^4.4.0",
"axios": "^1.5.1",
"dompurify": "^2.4.3",
"formik": "^2.2.9",
"graphql": "^16.5.0",
"graphql-request": "^5.1.0",
"html-entities": "^2.3.2",
"jquery-param": "^1.2.1",
"lodash": "^4.17.21",
"luxon": "^3.2.1",
"p-map": "^5.3.0",
"react": "^18.0.0",
"react-alert": "^7.0.3",
"react-block-ui": "^1.3.6",
"react-dom": "^18.0.0",
"react-helmet": "^6.1.0",
"react-query": "^3.34.16",
"react-router-dom": "^6.8.1",
"react-select": "^5.6.1",
"react-to-print": "^2.14.11",
"reactstrap": "^8.10.0",
"styled-components": "^5.3.6",
"uuid": "^9.0.0",
"zustand": "^4.3.2"
},
"devDependencies": {
"@availity/workflow": "^9.2.5",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^13.4.0",
"@types/dompurify": "^2.4.0",
"@types/jest": "^29.4.0",
"@types/jquery-param": "^1.0.2",
"@types/lodash": "^4.14.190",
"@types/luxon": "^3.2.0",
"@types/node": "^18.13.0",
"@types/react": "^18.0.27",
"@types/react-alert": "^7.0.2",
"@types/react-dom": "^18.0.10",
"@types/react-helmet": "^6.1.6",
"@types/react-router-dom": "^5.3.3",
"@types/react-select": "^5.0.1",
"@types/styled-components": "^5.1.24",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"cross-env": "^7.0.3",
"esbuild-loader": "^3.0.0",
"eslint-config-availity": "^8.0.7",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"lint-staged": "^13.1.1",
"prettier": "^2.8.4",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"typescript": "^4.9.5"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant