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

axios_1.default.post is not a function #64

Open
minhkhoi8888 opened this issue Sep 26, 2024 · 2 comments
Open

axios_1.default.post is not a function #64

minhkhoi8888 opened this issue Sep 26, 2024 · 2 comments

Comments

@minhkhoi8888
Copy link

image
Please help me this case

@nordost8
Copy link

nordost8 commented Oct 6, 2024

Hey, hope you’re doing well!

Here’s my project structure:

telegram-web-app-backend-deploy/
├── frontend/
│   ├── node_modules/
│   ├── public/
│   ├── src/
│   ├── .env.development
│   ├── config-overrides.js
│   ├── package.json
│   ├── README.md
│   ├── vercel.json
├── frontend-airdrop/
├── models/
├── sockets/
├── tests/
└── utils/

I had a similar issue with axios_1.default.post is not a function. To resolve it, I added a config-overrides.js file in the frontend folder containing the following logic:

const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');

module.exports = function override(config, webpackEnv) {
  const loaders = config.module.rules[1].oneOf;
  loaders.splice(loaders.length - 1, 0, {
    test: /\.(js|mjs|cjs|ts|tsx)$/,
    loader: require.resolve('babel-loader'),
    options: {
      presets: [require.resolve('babel-preset-react-app/dependencies')],
      cacheDirectory: true,
    },
  });
  return config;
};

For me axios_1.default.post is not a function happens because the module wasn’t being interpreted correctly by the bundler, and this override fixes that by configuring Babel to handle these module types properly.
Hopefully, this works for you too!

@hiendaovinh
Copy link

I think we could remove axios and use fetch by default.

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

3 participants