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

142
Views
Get source in constructor

I'm trying to make a search with autocomplete, tell me how I can get in the constructor an array of label and results with axios get

new Autocomplete(input, {
  source: (response) => {
    axios.get('{{ route('api.autocomplete) }}', {
          params: {
            term: input.value
          }
        })
      .then(response => {
        return {
          label: response.data.name,
          results: response.data.children,
        }
      })
  },
  select: ({element}) => {
    alert(element);
  }
});


class Autocomplete {
  constructor(element, {
    source = () => {},
    select = () => {},
  }) {
    console.log(source);

  }
}

Instead of an array, it gives out a piece of axios request code

about 4 years ago · Santiago Gelvez
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!