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

326
Visualizações
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 Respostas
Responde à pergunta

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