nuxt.jsnuxt-auth

How to use nuxtjs auth middleware with backed accepting querystring


I have example backend which issues JWT token but it is accepting username and password in query string.

I'm trying to use Nuxt JS auth middleware, how can I send username and password in querystring?

          login: {
            url: "http://localhost/api/v1/login/access-token",
            method: "post",
            headers: {
              "Content-Type": "application/x-www-form-urlencoded",
              "grant_type": "password"
            }
          },

And in login.vue

const response = await this.$auth.login({ data: this.form }); which is clearly wrong but how can I make sure the form data encoded in url and not in request body.


Solution

  • Just do like this and it will work

    let response = await this.$auth.loginWith('local',{data:`username=${this.email}&password=${this.password}`});