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

230
Views
API: no detectado (en promesa) SyntaxError: final inesperado de la entrada

Tengo un archivo html básico que incluye entrada y botón. Quiero tomar este valor de entrada y enviarlo a la API. Api acepta solicitudes POST. Pero cuando hago clic en el botón Cambiar datos, me da Uncaught (en promesa) SyntaxError: final inesperado de la entrada

Aquí está mi código javascript -

 let input = document.querySelector("input") let button = document.querySelector("button") button.addEventListener("click", () => { let number = Number(`${input.value}`); console.log(number) async function postData(url = 'https://us-central1-smartkarabakh.cloudfunctions.net/main/main/setLedData', data = {}) { // Default options are marked with * const response = await fetch(url, { method: 'POST', // *GET, POST, PUT, DELETE, etc. mode: 'no-cors', // no-cors, *cors, same-origin headers: { 'Content-Type': 'application/json' // 'Content-Type': 'application/x-www-form-urlencoded', }, redirect: 'follow', // manual, *follow, error referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url body: JSON.stringify(data) // body data type must match "Content-Type" header }); return response.json(); // parses JSON response into native JavaScript objects } postData('https://us-central1-smartkarabakh.cloudfunctions.net/main/main/setLedData', { ledEnergy: number }) .then(data => { console.log(response.json()); // JSON data parsed by `data.json()` call }); })
about 4 years ago · Juan Pablo Isaza
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!