axios-module icon indicating copy to clipboard operation
axios-module copied to clipboard

fix: Nuxt3 module & plugin

Open Denoder opened this issue 3 years ago • 14 comments

Applying what I did here: https://github.com/nuxt-community/axios-module/issues/536#issuecomment-1029286844 to the actual module.

Denoder avatar Feb 05 '22 05:02 Denoder

Would love to see this merged 👀

nklsw avatar Mar 06 '22 06:03 nklsw

@pi0 can you please take a look at this? This is blocking me from starting a new nuxt3 project :/

EDIT: @aldarund @anteriovieira @Atinux @codebender828 @danielroe @DavidBernal @dotneet @farnabaz @gaetansenn @hmsk @JulienTant @kevinmarrec @lihbr @limichange @lupas @manniL @mvrlin @NicoPennec @paulgv @pimlie @potato4d @qm3ster @ricardogobbosouza @sam3d @Tabrizian @vuchl @warriorBrian can someone please take a look?

d3473r avatar Mar 16 '22 17:03 d3473r

Thank you for the PR @Teranode

Actually this is more complex that it seems since in Nuxt 3 we do have direct function call when making local request to the server.

See more on https://v3.nuxtjs.org/docs/migration/component-options#isomorphic-fetch

What are the features that you need from axios that you cannot do with $fetch in Nuxt 3?

atinux avatar Apr 04 '22 10:04 atinux

@Atinux Wasn't about features that I needed, the auth module used this module to function, and the auth module itself is taking long to release so ended up having to convert that too.

https://github.com/Teranode/nuxt-module-alternatives

Denoder avatar Apr 04 '22 11:04 Denoder

@Teranode A new auth module for Nuxt 3 is planned in Q2 2022

Intevel avatar Apr 04 '22 11:04 Intevel

@Intevel I am aware of that.

Denoder avatar Apr 04 '22 11:04 Denoder

@Teranode Thanks for your initiative and efforts for Nuxt 3 compatibility of this module.

I'm the author of axios, proxy, and auth modules (as well as Nuxt3!). All 3 modules were deeply designed to work well with the Nuxt 2 server architecture and even if we make our best to make them "just working" with Nuxt 3, they are not close to Nuxt 3 compatibility. Base URL handling, ESM and fetch support (for non-node.js servers) are essentially missing features from the axios module.

Regardless, I agree, that we should have basic compatibility for popular modules like axios and proxy, making migration easier.

pi0 avatar Apr 04 '22 12:04 pi0

In general I think it would be too much work to update the auth-module to be Nuxt 3 compatible. I understand the idea, the axios module is the third most installed.

Intevel avatar Apr 04 '22 12:04 Intevel

@pi0 It was a fun experience for me. On a side not, I do wonder how the proxy module will work considering that when using the function-based approach it wont work and had to resort to generating files inside the server folder (using the vite settings also had the same issue.).

@Intevel It works for the most part, there are a few bugs here and there (if people tell me what they are), the one glaring issue that I'm facing currently is that axios, pinia, and auth (or really any plugin that also has server sided capabilities) aren't available on the client side when using global middleware

Denoder avatar Apr 04 '22 12:04 Denoder

fetch support (for non-node.js servers)

Also (besides nuxt3's built in functions) wouldn't nuxt/http work for that? @pi0

Denoder avatar Apr 04 '22 13:04 Denoder

What are the features that you need from axios that you cannot do with $fetch in Nuxt 3?

@Atinux it would nice for $fetch to have a global set token function like $axios has.

djames-rms avatar Apr 04 '22 15:04 djames-rms

Should I close this, seeing as you are going to be using Nuxt's isomorphic fetch api?

Denoder avatar Apr 20 '22 22:04 Denoder

Hi @Teranode. Please keep it open i would love to continue on your work for at least basic compatibility with Nuxt3. Sorry it took long. There was tons of other stuff to work on.

BTW yes, please consider using Nuxt 3 native fetch/$fetch whenever possible!

pi0 avatar Apr 20 '22 23:04 pi0

If we want to switch from axios to Nuxt 3 fetch, what do we need to change in our code? Where's the docs on that?

bmulholland avatar Oct 31 '23 11:10 bmulholland