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

(0 , ms_1.default) is not a function #79

Open
MichaelLiss opened this issue Aug 12, 2024 · 0 comments
Open

(0 , ms_1.default) is not a function #79

MichaelLiss opened this issue Aug 12, 2024 · 0 comments

Comments

@MichaelLiss
Copy link

Here is the error:

(0 , ms_1.default) is not a function
TypeError: (0 , ms_1.default) is not a function
    at authTokenInterceptor (http://localhost:3000/static/js/bundle.js:9825:34)
    at applyAuthTokenInterceptor (http://localhost:3000/static/js/bundle.js:9503:82)
    at ./src/components/axiosApi/axiosApi.js (http://localhost:3000/static/js/bundle.js:585:69)
    at options.factory (http://localhost:3000/static/js/bundle.js:61632:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:61053:32)
    at fn (http://localhost:3000/static/js/bundle.js:61290:21)
    at ./src/components/funds/Funds.js (http://localhost:3000/static/js/bundle.js:954:76)
    at options.factory (http://localhost:3000/static/js/bundle.js:61632:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:61053:32)
    at fn (http://localhost:3000/static/js/bundle.js:61290:21)

here is the code:

import axios from 'axios';
import { applyAuthTokenInterceptor } from 'axios-jwt';

import { base_url } from '../../environment/url';

const axiosInstance = axios.create({ baseURL: base_url });

const requestRefresh = (refresh) => {
  return axios.post(`${base_url}auth/refreshtoken`, { refresh }).then((response) => response.data.token);
};

axiosInstance.interceptors.request.use((config) => {
  const jwt = sessionStorage.getItem('jwt');
  if (jwt) {
    config.headers.Authorization = `Bearer ${jwt}`;
  }
  return config;
});

applyAuthTokenInterceptor(axiosInstance, { requestRefresh });

export default axiosInstance;

here is axiosapi.js

import axios from 'axios';
import { applyAuthTokenInterceptor } from 'axios-jwt';

import { base_url } from '../../environment/url';

const axiosInstance = axios.create({ baseURL: base_url });

const requestRefresh = (refresh) => {
  return axios.post(`${base_url}auth/refreshtoken`, { refresh }).then((response) => response.data.token);
};

axiosInstance.interceptors.request.use((config) => {
  const jwt = sessionStorage.getItem('jwt');
  if (jwt) {
    config.headers.Authorization = `Bearer ${jwt}`;
  }
  return config;
});

applyAuthTokenInterceptor(axiosInstance, { requestRefresh });

export default axiosInstance;

Here is my package.json

{
  "name": "name",
  "version": "0.0.1",
  "private": true,
  "engines": {
    "node": "18.18.0",
    "npm": "10.8.2"
  },
  "dependencies": {
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "@testing-library/jest-dom": "^6.4.8",
    "@testing-library/react": "^16.0.0",
    "@testing-library/user-event": "^14.5.2",
    "axios": "^1.7.3",
    "axios-jwt": "^4.0.3",
    "ms": "^2.1.3",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-icons-kit": "^2.0.0",
    "react-images-uploading": "^3.1.7",
    "react-modal": "^3.16.1",
    "react-router-dom": "^6.26.0",
    "react-scripts": "5.0.1",
    "ultimate-react-multilevel-menu": "^3.4.9",
    "web-vitals": "^4.2.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "heroku-postbuild": "npm run build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
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