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

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

Closed
addisonhardy opened this issue Oct 6, 2022 · 76 comments
Closed

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

addisonhardy opened this issue Oct 6, 2022 · 76 comments

Comments

@addisonhardy
Copy link

addisonhardy commented Oct 6, 2022

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
@pablo-the-dev
Copy link

pablo-the-dev commented Oct 6, 2022

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

@CarlLindqvist
Copy link

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

@addisonhardy
Copy link
Author

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.

@pablo-the-dev
Copy link

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.

@rwging
Copy link

rwging commented Oct 6, 2022

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

@addisonhardy
Copy link
Author

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.

@DevMukhtarr
Copy link

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

@addisonhardy
Copy link
Author

@jasonsaayman Tagging for visibility.

@andrewsaraceni
Copy link

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

@jkira
Copy link

jkira commented Oct 6, 2022

Also having multiple broken production apps here.

@alessondejesus
Copy link

same, my production environment has broken

@tony-brandner
Copy link

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

@nicholasgomez-dev
Copy link

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

@MMtinker
Copy link

MMtinker commented Oct 6, 2022

same here! All apps using axios are broken!

@corey-c
Copy link

corey-c commented Oct 6, 2022

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

@addisonhardy
Copy link
Author

At the time of this comment:

@Bradford401
Copy link

axios.post not working as well

egaillot added a commit to betagouv/mon-service-securise that referenced this issue Oct 6, 2022
Axios a introduit une régression en livrant la version v1.1.0. Comme on chargeait
toujours la version la plus récente, on s'est retrouvé avec une version qui ne
marche pas.

(cf. axios/axios#5038)
egaillot added a commit to betagouv/mon-service-securise that referenced this issue Oct 6, 2022
Axios a introduit une régression en livrant la version v1.1.0. Comme on chargeait
toujours la version la plus récente, on s'est retrouvé avec une version qui ne
marche pas.

(cf. axios/axios#5038)
@jqr108
Copy link

jqr108 commented Oct 6, 2022

gotta git get imo

@AnnAngela
Copy link

AnnAngela commented Oct 7, 2022

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 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@d70785b):

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

@AnnAngela
Copy link

AnnAngela commented Oct 7, 2022

To be honest, this change addressed type definition issue indeed, I don't need this JSDoc comment at all:

/**
 * @type {axios.AxiosStatic}
 */

So I would like to suggest that the change should be disclosed rather than reverted.

@masa172
Copy link

masa172 commented Oct 7, 2022

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

@craftxbox
Copy link

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!!)

@danveb
Copy link

danveb commented Oct 7, 2022

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.

@eliecer2000
Copy link

+1 :(

@quarantaquatro
Copy link

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.

@GeordieStew
Copy link

Update to v1.1.1 this should slove the issue

Thanks. Any idea how long these things take to reflect on CDNs generally? We're not pinned to a version. I've pinned back to 1.0.0 where possible but have some complex sites that rely on "latest version" from CDN. "https://unpkg.com/axios/dist/axios.min.js"

@guiolmar
Copy link

guiolmar commented Oct 7, 2022

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

@ScottDurkin
Copy link

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".

@anasau
Copy link

anasau commented Oct 7, 2022

Also getting 'Axios.post is not a function' when using "https://unpkg.com/axios/dist/axios.min.js".

@kloetje
Copy link

kloetje commented Oct 7, 2022

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

@AnnAngela
Copy link

@jasonsaayman In 1.1.1, the export is still in default =。=

image

@JoeyFenny
Copy link

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

@jasonsaayman
Copy link
Member

Yeah I see, it seems the browser bundle was also affected will fix

@ScottDurkin
Copy link

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.

@masa172
Copy link

masa172 commented Oct 7, 2022

Working at v1.1.2
Thanks.

@paauloedu
Copy link

I have the same problem with axios: "Uncaught TypeError: axios.get is not a function"

@gokaykucuk
Copy link

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.

@meddi-oficial
Copy link

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.

@yousef-iskandar
Copy link

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.

@bsssshhhhhhh
Copy link

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.

@SeinopSys
Copy link

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.

@camposyan
Copy link

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

@meddi-oficial
Copy link

You should update your version to 1.1.2. Otherwise, you have to use axios.default.get

@Daxcor69
Copy link

Daxcor69 commented Oct 7, 2022

1.1.2 gave me the same error, I had to go back to 1.1.0.

@foray1010
Copy link

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)

@MauiMan1
Copy link

MauiMan1 commented Oct 7, 2022

Following...

@arthurfiorette
Copy link
Contributor

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

@Jay-Madden
Copy link

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

@jasonsaayman
Copy link
Member

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.

@gondar00
Copy link

gondar00 commented Oct 8, 2022

Missing test case is the RCA for this issue, its best to add another test case such that this issue doesn't happen again in the future

foray1010 added a commit to foray1010/ignore-sync that referenced this issue Oct 8, 2022
@noscripter
Copy link

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

@sarbull
Copy link

sarbull commented Oct 9, 2022

it works on my machine

@axios axios locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests