ton-org / ton

Most popular TON Typescript Library
MIT License
161 stars 37 forks source link

axios_1.default.post is not a function #64

Open minhkhoi8888 opened 2 weeks ago

minhkhoi8888 commented 2 weeks ago

image Please help me this case

nordost8 commented 1 week ago

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!