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

324
Views
Vue multiselect and sending a query via axios call

I'm trying to use Vue-multiselect as an autocomplete search against a database, but I'm having issues as far as retrieving the query that I'm sending from the axios call.

I'm seeing the value that I'm typing in as 'val' within the function, but when I dump the query from the request in the controller it shows null ( looking at the request, the query param seems to be empty). I'm thinking there's an issue with how I'm sending it perhaps.

Is my function incorrect as far as how I'm sending the query?

Here's the code:

    <div class="form-group col-lg-4">
<h4>Copy Users</h4>
<br>
<multiselect 
    v-model="copyUsers" 
    :options="copyUsersOptions" 
    @search-change="val => searchCopiedUsers(val)"
    :multiple="true" 
    :loading="loading"
    placeholder="Enter user(s) to be copied" 
    label="name"
    track-by="value">
</multiselect>
</div>


loading:false,
copyUsers: [],
copyUsersOptions: [],
searchCopiedUsers: function(val) {
      console.log('searched for', val);
      if (val) {
        this.loading = true;
        this.copyUsersOptions = [];

        let self = this;

        axios.get('users/search',{params: {query: this.val}})
            .then(function (response) {
                self.options = response.data;
        });

      } else {
        this.options = [];
      }
},

controller.php

public function getUsers(Request $request)
{
    dd($request->get('query'));
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You're sending the data object this.val, which is what your vue app is storing as val in its local data store. Have you tried passing the value directly into the get request like this: axios.get('users/search',{params: {query: val}})?

over 4 years ago · Santiago Trujillo 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!