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

201
Views
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 answers
Answer question

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 Report
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!