Affichage des articles dont le libellé est async promise await. Afficher tous les articles
Affichage des articles dont le libellé est async promise await. Afficher tous les articles

Async wait Promise

<!DOCTYPE html>
<html lang="en">
<body>
    <script>
        function sleep(ms) {
            return new Promise(resolve => setTimeout(resolve, ms));
        }
        const annoncement = async () => {
            document.body.insertAdjacentHTML("afterBegin"
, `<h1 id="info">date: ${new Date().toLocaleDateString()}</h1>`);
            await sleep(3000)
            document.querySelector("#info").remove();
        }
        annoncement();
    </script>
</body>

</html>