Denoder / nuxt-module-alternatives

Alternative modules to use while waiting for Nuxt 3 Compatibility
MIT License
144 stars 14 forks source link

TypeError: $fetch.$post is not a function #135

Closed Natronick closed 1 year ago

Natronick commented 1 year ago

Environment

Nuxt Config

// https://v3.nuxtjs.org/api/configuration/nuxt.config export default defineNuxtConfig({ ssr: true, typescript: { shim: false, }, modules: [ '@nuxtjs/tailwindcss', '@nuxtjs-alt/auth', '@nuxtjs-alt/http', '@nuxtjs-alt/proxy', '@pinia/nuxt', ], auth: { strategies: { github: { clientSecret: 'my_secret', clientId: 'my_id', }, }, }, });

Reproduction

I can't share my github oauth secrets. I made a very simple nuxt app to try login to github using your module.

Describe the bug

During the oauth2 code redirect process my nuxt server try to make an api call to retrieve the access token in exchange of the oauth2 code using this call (from src/utils/provider.ts):

              $fetch.$post(options.tokenEndpoint, {
                  body: data,
                  headers
              })
              .then((response) => {
                  event.res.end(JSON.stringify(response))
              })
              .catch((error) => {
                  event.res.statusCode = error.response.status
                  event.res.end(JSON.stringify(error.response.data))
              })

But it seems that $fetch is not an instance but un function to get the instance. I've probably misconfigured something but i can't figure out what.

I tried to change $fetch.$post by $fetch().$post then it worked as expected.

Additional context

No response

Logs

No response

Denoder commented 1 year ago

I've updated the auth module.

Natronick commented 1 year ago

It works fine, thank you very much!