axios: TypeError: axios.get is not a function (v1.1.0)

Describe the bug

The new version of axios (v1.1.0) is throwing an error for axios.get: TypeError: axios.get is not a function.

Note: This issue was not present in v1.0.0

To Reproduce

Include axio v1.1.0 via a <script> tag, and then reference it directly via axios.get()

<script src="https://unpkg.com/axios@1.1.0/dist/axios.min.js"></script>
<script>
    axios.get(...)
</script>

Expected behavior

axios.get should be a valid function.

Environment

  • Axios Version 1.1.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 86
  • Comments: 76 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Why you guys don’t point to a specific version is far beyond me.

I think anyone who is having this problem should really get some consultancy about how to deploy applications to prod.

I’m not trying to be condescending. I’m telling this because all your deployments are wide open to a supply-chain attack which is even worse than having your prod broken.

I sincerely hope every single one of those who were complaining about the 1000+ production websites this just broke have now each contributed hundreds of dollars to the maintainers of this package to recognize all the labour they have been so carelessly profiting off of so far.

I am experiencing this breaking change, my production app is broken and unusable to my clients.

I think anyone who is having this problem should really get some consultancy about how to deploy applications to prod.

I’m not trying to be condescending. I’m telling this because all your deployments are wide open to a supply-chain attack which is even worse than having your prod broken.

More specifically:

  • Test your package upgrades before deploying them to production. Anyone in this thread complaining about production being broken clearly didn’t do this. Outsourcing your QA efforts to your customers is not ideal.
  • Pin your package versions. Just because your project currently works with one version of the package does not mean it will work with another.

Me three. Prod is down. Got woken up here by confused users

Production broken as well, more than 2200 websites created on our plateform Tiktak PRO are no more working ! please revert !

Confirmed as breaking production applications on my end as well. This is a big miss in testing coverage for a library like this.

Pinning axios back to v0.27.2 (https://unpkg.com/axios@0.27.2/dist/axios.min.js) does resolve the issue if anyone is looking for a temporary solution.

I’ve tested and confirmed going to version 1.0.0 also works, problem is that will require app store review. IMO the devs should roll the distribution back.

Can we lock this issue to avoid spam? They ran into this issue (in production) because they didn’t pinned their dependencies correctly.

Also having multiple broken production apps here.

It affected my app in production too, axios is not a function.

Can repro. This is causing major issues with an electron app of mine. Axios is used via unpkg versionless inside of the asar and there is no way to notify users to update as all requests to autoupdater are handled through axios… This should be reverted, and such a breaking change should have been communicated well in advance (and NOT distributed under a semver minor change!!)

same, my production environment has broken

I am going to have a fix out in the next hour

same here! All apps using axios are broken!

Good god y’all, pin your dependencies. If your app can’t handle an outage then make sure your versions are locked.

A major breaking change to a project this big is not acceptable. This should have been handled differently:

  • Deprecate the functions MONTHS in advance, giving warnings when used. Finally in the breaking version, the breaking change should give a verbose error message when used.
  • Use a major version for breaking changes (i.e. 1.0.0 -> 2.0.0
  • Provide a migration guide to fix these changes.

Following…

Will start looking into this today, once again sorry about this.

i am supposed to film a demo of my website I built that not is not functioning becuase of this. I have a few hours. How long will the repair take??

We are also experiencing this issue, and will have to wait for app store review for a fix unless the hosted code can be fixed. Adding to the vote for roll back to 1.0

Pinning axios back to v0.27.2 (https://unpkg.com/axios@0.27.2/dist/axios.min.js) does resolve the issue if anyone is looking for a temporary solution.

I’m having the same error ‘axios.get is not a function’. All my requests are broken now.

I found out that the module.exports of axios@1.1.0 has been changed from axios@1.0.0, which introduced in #5003 and #5030. These PR made the module.exports completely changed showing in https://github.com/axios/axios/compare/v1.0.0...v1.1.0#diff-e114a79086c5cde98bca3f766534b7f86a1093035560390daa3a2192047289d9L3749-R3760 and making NodeJS users’ code breaking at all.

@jasonsaayman I think this is an incompatible breaking change that should be reverted or disclosed.


FYI, If you are a NodeJS user, using commonJS and want to use original interface of axios, you should use require("axios").default instead of require("axios") (example: MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes@d70785bf742c4798ab366b70768f54f404d3c4d3):

const axios = require("axios").default;

If you use ESM, there is nothing you should do since the interface doesn’t change.


If you uses axios@1.1.0 in browser, you , you should use axios.default instead of axios:

axios.default.get("http://www.google.com/generate_204");

// or if you don't care `AxiosHeaders` which is only available in `axios` object (`axios.AxiosHeaders`),
// you can directly override it
const axios = axios.default;
axios.get("http://www.google.com/generate_204");

image

Common, we fixed prod yesterday using axios.default, and now is broken again lol. Gotta use https://unpkg.com/axios@0.27.2/dist/axios.min.js until they decide if it is going to be axios.default or axios.

For anyone calling the non version specific unpkg CDN link you can switch to this version to fix the current problem

https://unpkg.com/axios@1.0.0/dist/axios.min.js

I think anyone who is having this problem should really get some consultancy about how to deploy applications to prod.

I’m not trying to be condescending. I’m telling this because all your deployments are wide open to a supply-chain attack which is even worse than having your prod broken.

This is a good point, but consider the README.md explicitly encourages this usage of the package.

Experiencing issues as well on production apps. Error: “axios is not a function”

bhai jaldi fix kar do , client ne kand asamjh liya

please revert it.

Major issues on our sites, had to change and pin to 0.27.0

What you can learn from this issue:

  • you don’t need axios actually, instead use XHR/Fetch or etc directly plz
  • please lock up your dependencies for production environments/releases

Thanks for all the feedback everyone, also some great pointers here on how to manage your own software. On the way Axios should work when using it with Common JS it should always be:

const axios = require('axios')

I will work to make sure this is always the case. I will also update all the docs etc ASAP. Lastly, I will fix the problems that seem to now exist when using Type Script. I know this was a rough release, but I will endeavour to make them more smooth from here on.

Why you guys don’t point to a specific version is far beyond me.

I have to agree even though I am guilty of this. Learn’t a lesson today.

+1 😦

Production is broken for me as well… Any sign of a fix incoming?

Working at v1.1.2 Thanks.

Update to v1.1.1 this should slove the issue

Still have “axios.get is not a function” error while using “https://unpkg.com/axios/dist/axios.min.js”.

Update to v1.1.1 this should slove the issue

It seems that the “axios.get is not a function” error is still on version 1.1.1

gotta git get imo

At the time of this comment:

@jasonsaayman Tagging for visibility.

I’ve tested and confirmed going to version 1.0.0 also works, problem is that will require app store review. IMO the devs should roll the distribution back.

It looks like version 1.0.0 had an issue affecting commonjs/umd exports (axios.default). I think this regression happened during the work to fix that issue.

We are also having this issue with ‘https://az416426.vo.msecnd.net/scripts/a/ai.0.js

ROLL BACK TO 0.27

Thank you! Just downgraded axios back to v1.0.0. Was playing around with an API with v1.1.0 and all hell broke loose.

An error “TypeError: axios.get is not a function” on the latest v1.1.0 was detected today. To use the version 1.0.0->1.1.2 instead is a better way to avoid the error for now. Hope to be resolved this issue immediately.

Oct. 7th, Working at v1.1.2

axios.post not working as well

Since the latest versions, there are two groups of users with different ways importing axios

  1. const axios = require('axios')
  2. const axios = require('axios').default

IMO, it would be ideal if we can find a way to support both styles, if not, we have to choose one and declare the other one invalid (which I think is 1 because 2 is stated in README)

Also getting ‘Axios.post is not a function’ when using “https://unpkg.com/axios/dist/axios.min.js”.

Update to v1.1.1 this should slove the issue

I’m going to try it!

using @AnnAngela 's findings const axios = require("axios").default; solved it for me, however this would break any living app these elements should go back to root

This just killed 3 of my client’s applications with this problem. I downloaded the old 1.0.0 and used it locally on all applications until this is solved in 1.1.0. I recommend for everyone do the same.