Почему при повторе if код портится JS

При повторе условного оператора код портится. Через else if тоже самое. При таком раскладе все пашет

<script>

        async function GetUsers(id) {
            const response = await fetch("/api/values/" + id, {
                method: "GET",
                headers: { "Accept": "application/json" }
            });
            if (response.ok === true) {
                const items = await response.json();
                items.forEach(article => {
                    if (article.item_type == 'p') {
                        let p = document.createElement('p');
                        p.innerHTML = article.сontent;
                        document.body.append(p);
                    }
                });
            }
        }


        var the_id = window.location.pathname;
        re = /[0-9]/
        found = the_id.match(re)


        GetUsers(found );

    </script>

А так уже вообще нет

<script>

    async function GetUsers(id) {
        const response = await fetch("/api/values/" + id, {
            method: "GET",
            headers: { "Accept": "application/json" }
        });
        if (response.ok === true) {
            const items = await response.json();
            items.forEach(article => {
                if (article.item_type == 'p') {
                    let p = document.createElement('p');
                    p.innerHTML = article.сontent;
                    document.body.append(p);
                }
                if (article.item_type == 'h1') {
                    let h1 = document.createElement('h1');
                    p.innerHTML = article.сontent;
                    document.body.append(h1);
                }

                if (article.item_type == 'h3') {
                    let h3 = document.createElement('h3');
                    p.innerHTML = article.сontent;
                    document.body.append(h3);
                }
            });
        }
    }


    var the_id = window.location.pathname;
    re = /[0-9]/
    found = the_id.match(re)


    GetUsers(found);

</script>

Ошибка: 2:54 Uncaught (in promise) ReferenceError: p is not defined at 2:54 at Array.forEach () at GetUsers (2:50)


Ответы (0 шт):