Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
VueJS - Best way to open global modal login form

My VueJs project uses Axios to send server requests. Some of server-side requests needs authenticated user with JWT.

I would like to make a generic client-side service to make these authenticated requests and, if not authenticated, my user needs to be shown a modal login form.

So, I created a Mixin to do so:

import ModalLogin from '../../components/ModalLogin';
import Vue from 'vue'

export default {
    components: {
        ModalLogin
    },
    data: function () {
        return {
            ModalLoginComponent
        }
    },
    methods: { 
        authorizedGet(url) {
            if(!localStorage.getItem('user')) {
                this.instantiateModal()
                this.data().ModalLoginComponent.methods.show()
            }
        },
        instantiateModal() {
            var ModalLoginClass = Vue.extend(ModalLogin)
            this.ModalLoginComponent = new ModalLoginClass()
            this.ModalLoginComponent.$mount()
        }
    }
}

and a basic ModalLogin component. But, obviously, I don't know how to add my ModalLogin to my DOM from a mixin. I'd like my modal to be global for all my app.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!