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

320
Views
¿Por qué no se puede usar la función findOne() en scripts?
<button class="button is-link" type="submit" onclick="matching('<%= product.id %>')">Define</button>

El HTML del botón.

 <script> async function matching(productID) { var r = confirm("Define preference?"); if (r) { alert("testing1") var thatProduct = await PriceTracker.findOne(productID); alert("testing2") if (thatProduct) { alert("Have that product"); location.assign("/"); } else if (response.status == 409) { var e = await response.json(); alert(e); } else if (response.status == 404) { var e = await response.json(); alert(e); } } else { alert(response.statusText); } } </script>

Este es el código para una función de coincidencia con el marco de velas.

Cuando hago clic en un botón, se llamará a la función correspondiente.

Se puede mostrar el cuadro de confirmación. Cuando hago clic en 'ok', también se puede mostrar el mensaje de alerta de "testing1", mientras que el segundo mensaje de alerta "testing2" no se pudo mostrar y, por lo tanto, tampoco se puede alcanzar la condición "if".

¿Cómo puedo obtener ese producto de mi base de datos para su uso posterior?

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

0

await no funcionará en el código de nivel superior

Cambie su función matching en esto

 var matching = (async (productID) => { try { ... } catch (e) { // handle the error ... } })();
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!