Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
Re-creating a method which is already in component inside a store js file in Vue

This can be a simple question but since I'm in a learning curve of vuejs I'm struggling to achieve following task.

I have this method inside one of my vue component.

async loadSuggestedUsers() {
            if (!this.suggestionUrl) return false
            else this.isSearching = true;

            this.cancelPreviousRequest();

            await axios.get(`/${Helper.getLocale()}/dashboard/${this.suggestionUrl}`, {
                params: {
                    page: this.suggestedUsersData.page,
                    per_page: this.suggestedUsersData.perPage,
                    search_text: this.searchText,
                    nationality: this.selectedNationalities
                },
                cancelToken: this.requestToken.token
            }).then(({data}) => {
                collect(data.data).each((user) => {
                    if (!this.suggestedUsers.some(obj => obj.id === user.id)) {
                        this.suggestedUsers.push(user)
                    } else if (
                        user.project_specific_job_title_id &&
                        !this.suggestedUsers.some(obj => obj.project_specific_job_title_id === user.project_specific_job_title_id)
                    ) {
                        this.suggestedUsers.push(user)
                    }
                })
                this.suggestedUsersData.perPage = data.per_page
                this.suggestedUsersData.total = data.total

                this.isSearching = false
            }).catch(error => {
                if (error instanceof axios.Cancel) return false;
            });
        },

but now, Instead of directly calling this method from the component I'm trying to access this by using store .

Under my store, I have a js file called, TestStore.JS

My questions are,

How can I re-create above method in my TestStore.JS and how call that recreated method in my component...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

One solution is to create a state for this function in your store and pass its reference to it in the created lifecycle of the component.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda