Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
How can I slow down readings I get from a QR Scanner?

this is my first post. greetings to readers.

So Im fairly new to coding, and ive got this code implemented onto my frontend, a succesful scan sends a GET request to my python API to fetch data from database.. but this script scans qr code few times a second (not only that but it submits it too).

So my question is how could I slow it down a bit, lets say a timeout for 2 seconds after a succesful scan?

 function onScanSuccess(decodedText, decodedResult) {
    // Handle on success condition with the decoded text or result.
    console.log(`Scan result: ${decodedText}`, decodedResult);
    $('#search').val(decodedText);
    $('#frm').submit();
}

var html5QrcodeScanner = new Html5QrcodeScanner(
    "reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
});

edit: I havent said I didnt write this and I have no idea how to do timeouts in Typescript or Javascript and not even where.

Im thanking you for your time :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is taken directly from the html5QrcodeScanner example. On success, it will update the result, and if there's no new result scanned, it wont update the result

var resultContainer = document.getElementById('qr-reader-results');
var lastResult, countResults = 0;

function onScanSuccess(decodedText, decodedResult) {
    if (decodedText !== lastResult) {
        ++countResults;
        lastResult = decodedText;
        // Handle on success condition with the decoded message.
        console.log(`Scan result ${decodedText}`, decodedResult);
    }
}

var html5QrcodeScanner = new Html5QrcodeScanner(
    "qr-reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);

but this wont stop your device from scanning, it just won't update the result as from my understanding of your question that would be sufficient, but if you want to stop the camera/ scanning process altogether after successful scan, you can go into a lil bit advanced part of the library

import {Html5Qrcode} from "html5-qrcode"

const html5QrCode = new Html5Qrcode("reader");

html5QrCode.stop().then((ignore) => {
  // QR Code scanning is stopped.
}).catch((err) => {
  // Stop failed, handle it.
});

by doing this also means that you need to implement the whole process from Pro Mode, you can refer here for pro mode

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda