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

173
Views
¿Cómo cargo una tienda Alpine con valores asíncronos de una llamada de búsqueda?

Intentando cargar una tienda Alpine con valores (una lista de matrices) desde una llamada API. La búsqueda devuelve una promesa, por lo que busca la mejor manera de cargar esto directamente:

 document.addEventListener('alpine:init', () => { Alpine.store('myStore', { my_data: fetch('/api/1') .then(response => response.json()) }) })

No me comprometo a buscar, pero lo que sea más fácil de agregar directamente a la tienda.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

invertirlo Obtenga los datos primero y luego cree la tienda una vez que se resuelva

 document.addEventListener("alpine:init", async () => { const res = await fetch("/api/1"); if (!res.ok) { throw new Error(`${res.status}: ${await res.text()}`); } Alpine.store("myStore", { my_data: await res.json(), }); });
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!