3

TypeError: axios.get is not a function (v1.1.0) · Issue #5038 · axios/axios · Gi...

 1 year ago
source link: https://github.com/axios/axios/issues/5038
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Comments

addisonhardy commented 2 days ago

edited

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/[email protected]/dist/axios.min.js"></script>
<script>
    axios.get(...)
</script>

Expected behavior

axios.get should be a valid function.

Environment

  • Axios Version 1.1.0
andaryjo, pablo-the-dev, bnewman200, CarlLindqvist, DevMukhtarr, waikiwong, christophorusdou, andrewsaraceni, Anish-Agnihotri, Bradford401, and 66 more reacted with thumbs up emojiolarende-fortum, dromzeh, nico-abram, tilwinjoy, and aeros281 reacted with confused emojimanueltarouca, andormade, and jjliggett reacted with eyes emoji All reactions

pablo-the-dev commented 2 days ago

edited

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

psychotoad, eschwartz, Qix-, Agreon, tgfischer, gokaykucuk, TarasHots, DiamondMiner88, Nincodedo, ViPeev, and 39 more reacted with thumbs down emojijulien-lecomte, Simonwep, mozvip, TorbenKoehn, sharpSteff, MatiasColil, AliKarpuzoglu, MattBidewell, Nazzanuk, joao-esteves, and 5 more reacted with laugh emojieduardogpg reacted with confused emojifungiboletus, mozvip, jjliggett, Hoffa1337, and Dedox-tech reacted with eyes emoji All reactions

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

hiteshkoli, Plutonium244, kashcode, rohit-gh, Genda1ph, lyptt, and yellowcherry21 reacted with thumbs up emojipsychotoad, Qix-, tgfischer, chrislambe, DiamondMiner88, Nincodedo, JohannesM, Omkar76, 3mcd, llamasoft, and 31 more reacted with thumbs down emojijulien-lecomte, Simonwep, mozvip, sharpSteff, TorbenKoehn, MattBidewell, Nazzanuk, andormade, BryceMehring, and tilwinjoy reacted with laugh emoji All reactions

Author

addisonhardy commented yesterday

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

dimater, rohit-gh, fkaragic, malbur, aembleton, joemackay, Dem1se, Spuffynism, ddugovic, riseres, and 7 more reacted with thumbs up emoji All reactions

Pinning axios back to v0.27.2 (https://unpkg.com/[email protected]/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.

psychotoad, Qix-, gokaykucuk, chrislambe, glenngijsberts, Nincodedo, luke-single, Omkar76, tmladek, ZacheryFaria, and 24 more reacted with thumbs down emojiSimonwep, gorel, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

rwging commented yesterday

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

curbelo-gonzalo, strager, AliKarpuzoglu, michael42, joao-esteves, 0x962, arthurfiorette, lucasyvas, ahinkle, nico-abram, and alexgallardo reacted with thumbs down emojitilwinjoy reacted with laugh emoji All reactions

Author

addisonhardy commented yesterday

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.

zaq42, dtobi59, Genda1ph, and lyptt reacted with thumbs up emoji All reactions

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

Nincodedo, xTachyon, marekr, HeavenVolkoff, curbelo-gonzalo, k-o-j-o, bhainesva, michael42, joao-esteves, gdmc-h, and 7 more reacted with thumbs down emojijulien-lecomte, mozvip, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

Author

addisonhardy commented yesterday

@jasonsaayman Tagging for visibility.

ahinkle reacted with thumbs down emoji All reactions

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

Ben-Wormald, cednore, alissaciel, coderdre, stephantabor, lyptt, RokasMuningis, 2017mike, and strimio reacted with thumbs up emojiQix-, gampu, Nincodedo, luke-single, bermudalocket, DeluxeOwl, JohannesM, cdcooksey, Omkar76, jnnrz, and 19 more reacted with thumbs down emojijulien-lecomte, Simonwep, mozvip, TorbenKoehn, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

jkira commented yesterday

Also having multiple broken production apps here.

JohannesM, cdcooksey, Omkar76, jnnrz, niorin, xTachyon, TorbenKoehn, curbelo-gonzalo, k-o-j-o, bhainesva, and 9 more reacted with thumbs down emojijulien-lecomte, mozvip, TorbenKoehn, juanlizarazo, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

same, my production environment has broken

JohannesM, cdcooksey, jnnrz, niorin, curbelo-gonzalo, k-o-j-o, michael42, joao-esteves, 0x962, andormade, and 3 more reacted with thumbs down emojijulien-lecomte, tmladek, Simonwep, mozvip, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

My production has broken as well.

JohannesM, cdcooksey, Omkar76, jnnrz, niorin, b12f, xTachyon, alexbujenita, curbelo-gonzalo, k-o-j-o, and 12 more reacted with thumbs down emojijulien-lecomte, hevans90, tmladek, Simonwep, mozvip, joao-esteves, and tilwinjoy reacted with laugh emoji All reactions

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

curbelo-gonzalo, bhainesva, michael42, joao-esteves, gdmc-h, 0x962, andormade, arthurfiorette, and lucasyvas reacted with thumbs down emoji All reactions

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

curbelo-gonzalo, bhainesva, michael42, joao-esteves, gdmc-h, 0x962, andormade, arthurfiorette, and lucasyvas reacted with thumbs down emojitilwinjoy reacted with laugh emoji All reactions

same here! All apps using axios are broken!

JohannesM, cdcooksey, Omkar76, jnnrz, niorin, Simonwep, b12f, xTachyon, curbelo-gonzalo, k-o-j-o, and 8 more reacted with thumbs down emoji All reactions

corey-c commented yesterday

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

https://unpkg.com/[email protected]/dist/axios.min.js

egaillot, MMtinker, cfx-rda-dev, yuhwan, 44u, Plutonium244, Eerovil, dutchybeatz, aycetiner, aembleton, and 6 more reacted with thumbs up emoji All reactions

Author

addisonhardy commented yesterday

LeandroGazoli, curbelo-gonzalo, and strager reacted with thumbs up emoji All reactions

axios.post not working as well

ahinkle reacted with thumbs down emoji All reactions

jqr108 commented yesterday

gotta git get imo

ahinkle reacted with thumbs down emoji All reactions

AnnAngela commented yesterday

edited

I found out that the module.exports of [email protected] has been changed from [email protected], 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 [email protected] 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
Chicooz, ThomOrlo, benmotyka2, romankm, staniel359, I-Vargas, lyptt, EnriqueMCHA, LeandroGazoli, gunslingster, and candy02058912 reacted with thumbs up emojiChicooz, BreadGenie, and EnriqueMCHA reacted with hooray emojiChicooz and EnriqueMCHA reacted with rocket emoji All reactions

AnnAngela commented yesterday

edited

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 commented yesterday

edited

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

ahinkle reacted with thumbs down emoji All reactions

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

cdcooksey, ZacheryFaria, jnnrz, JimmayVV, tomrcht, b12f, xTachyon, marekr, HeavenVolkoff, strager, and 11 more reacted with thumbs down emoji All reactions

danveb commented yesterday

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.

ahinkle reacted with thumbs down emoji All reactions
JohannesM, DpVic, michael42, 0x962, jrudder, ahinkle, and atdt reacted with thumbs down emoji All reactions

Member

jasonsaayman commented 23 hours ago

Update to v1.1.1 this should slove the issue

Update to v1.1.1 this should slove the issue

I'm going to try it!

ahinkle reacted with thumbs down emoji All reactions

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"

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

Junus, yogesh-morankar, and Rivera-Emmanuel reacted with thumbs up emoji All reactions

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, guiolmar, and yogesh-morankar reacted with thumbs up emoji All reactions

anasau commented 22 hours ago

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

yogesh-morankar reacted with thumbs up emoji All reactions

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

ahinkle and tilwinjoy reacted with thumbs down emoji All reactions

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

image

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

ScottDurkin, andrei-popa, wex, camspiers, SampleServe-MikeFranklin, bramhaag, KarolS, elderapo, tomasr8, PhenX, and 223 more reacted with thumbs up emojiandy-potts-nutmeg, manueltarouca, tipsy, micalevisk, narigama, xTachyon, sharpSteff, Nezteb, joao-esteves, nussjustin, and 2 more reacted with laugh emojijulien-lecomte, mozvip, sharpSteff, Nezteb, LiterallyFabian, joao-esteves, 0x962, jakehamilton, and greendad reacted with hooray emojiven and greendad reacted with rocket emoji All reactions

Member

jasonsaayman commented 22 hours ago

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

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.

mendhak, BCarley, mozvip, strager, joao-esteves, and keif reacted with thumbs up emoji All reactions

Working at v1.1.2
Thanks.

filimanistr, cednore, and nightlyworker reacted with thumbs up emoji All reactions

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

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.

cosminmindru-omnifi, steprider0, lukaskl, Spuffynism, pohuing, fdemmer, philBrown, dblclik, nicosullivan, g0ddish, and 148 more reacted with thumbs up emojikevin-guertin, alexrafael10, cdcooksey, PauloVilarinho, gilice, elderapo, mlieberman85, xTachyon, TorbenKoehn, will-amaral, and 20 more reacted with hooray emoji All reactions

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

foray1010 reacted with thumbs up emojietienne-martin, bermudalocket, cdcooksey, xTachyon, curbelo-gonzalo, joao-esteves, gdmc-h, 0x962, andormade, and timbcodes reacted with thumbs down emojicoderdre reacted with eyes emoji All reactions

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.

szendihorvathjozsef reacted with laugh emojitmladek, ZacheryFaria, HappyZombies, barakplasma, joao-esteves, 2-bits, timbcodes, andrezgz, and Dedox-tech reacted with confused emoji All reactions

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.
Xylobol, gilice, mplewis, cstst, Kuinox, DpVic, JaKXz, rocksdanister, PillowPillow, mlieberman85, and 56 more reacted with thumbs up emoji All reactions

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.

marekr, NathenSample, timrbula, eps1lon, ADBurpitt, aarongoldenthal, h-sifat, rodrigojmr, will-amaral, TorbenKoehn, and 54 more reacted with thumbs up emojichrisbarmonde, meddi-oficial, and TorbenKoehn reacted with thumbs down emojicp3p0, joao-esteves, and ahinkle reacted with laugh emoji All reactions

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

michael42, Mando75, luke-single, andormade, andrezgz, ecyrbe, gergelypap, and tilwinjoy reacted with thumbs down emoji All reactions

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

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

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)

AnnAngela reacted with thumbs up emoji All reactions

Following...

nilllzz, 0x962, luke-single, andormade, patricksjackson, Matir, alvarlagerlof, andrezgz, Trinovantes, ahinkle, and 4 more reacted with thumbs down emoji All reactions

Sponsor

Contributor

arthurfiorette commented 10 hours ago

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

2-bits, luke-single, jakehamilton, arthurfiorette, intrnl, Neaox, RobertLemmens, micalevisk, Heliozoa, keif, and 13 more reacted with thumbs up emojiforay1010 and shiloh92 reacted with thumbs down emoji All reactions

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

omril1, sadn1ck, defaultbr, keogh, JimmyMultani, yawaramin, and alehuo reacted with thumbs up emojiahinkle and varnem2 reacted with thumbs down emoji All reactions

Member

jasonsaayman commented 1 hour ago

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK