Reusable MySQL + Express.js Backend for Beginners

I’ve recently put together a basic backend template using MySQL and Express.js, mainly for learning purposes and possibly to use it later in some smaller full-stack projects.
I tried to keep the structure simple and modular, so it can easily be reused and adapted for different use cases.

I’m wondering what you think about it:

In what kinds of small projects do you think this setup would be most useful?

What are some things I could improve in terms of code structure, security, or performance?

I also included a very small part of the frontend code, just to demonstrate how it might connect to the backend.

Any feedback or suggestions would be really appreciated — I’m trying to get better at writing clean and practical code!

const express = require('express');
const mysql = require('mysql');
const path = require('path');
const app = express();
app.use(express.static('public'));
const port = 3000;

const db = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: ''
});

app.listen(port, () => {
    console.log(`Server is running at http://localhost:${port}`);
});

function lekerdez(sql) {
    return new Promise((resolve, reject) => {
        db.query(sql, (err, result) => {
            if (err) reject(err);
            else resolve(result);
        });
    });
}

function kuld(res, promise) {
    promise.then((result) => {
        res.json(result);
    }).catch((err) => {
        res.json(err);
    });
}

app.get('/get_html/:filename', (req, res) => {
    res.sendFile(path.join(__dirname, 'public', req.params.filename));
});

app.get('/get_tablak', (req, res) => {
    const sql = 'SHOW TABLES';
    kuld(res, lekerdez(sql));
});

$(document).ready(function() {
    if ($("#content").attr("ures") == "true") {
        load();
        $("#content").attr("ures", "false");
    }
});

function load(url) {
    const urlToLoad = url ? url : 'tablak.html';
    const xhr = new XMLHttpRequest();
    xhr.open('GET', '/get_html/' + urlToLoad, true);
    xhr.send();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            $("#content").html(xhr.responseText);
        }
    };
}

function selectTable() {
    $('#tablazatHead #tablazatBody #tablazatHead2 #tablazatBody2').html('');
    fillTable('tablazatHead', 'tablazatBody', '/get_tablak/' + $('#lista').val(), 'onclick="sortElemek(event)"', 'onclick="sorKatt(event)"');
}

function sortElemek(event, tablaNev) {
    if (tablaNev == '') {
        const column = $(event.target).index();
        const table = $('#tablazatBody1');
        const rows = table.find('tr').get();
        rows.sort(function(a, b) {
            const A = $(a).children('td').eq(column).text().toUpperCase();
            const B = $(b).children('td').eq(column).text().toUpperCase();
            if (A < B) return -1;
            if (A > B) return 1;
            return 0;
        });

        $.each(rows, function(index, row) { table.append(row); });
    }
}

function sorKatt(event) {
    const tableName = $('#lista').val();
    if (tableName === '') {
        const row = $(event.target).parent().children('td').get();
        const id = $(row[0]).text();
        fillTable('tablazatHead2', 'tablazatBody2', `something/${id}`);
    }
}

function masikTabla() {
    $('#tablazatHead #tablazatBody #tablazatHead2 #tablazatBody2').html('');
    fillTable('tablazatHead', 'tablazatBody', '/other_something');
}

function fillTable(tablehead, tablebody, url) {
    return new Promise((resolve, reject) => {
        $(`#${tablehead}`).html('');
        $(`#${tablebody}`).html('');
        xhr = new XMLHttpRequest();
        xhr.open('GET', url, true);
        xhr.send();
        xhr.onreadystatechange = function() {
            var tabla = JSON.parse(xhr.responseText);
            if (xhr.readyState == 4 && xhr.status == 200) {
                if (url.search("/") != -1) {
                    xhr = new XMLHttpRequest();
                    xhr.open('GET', '/', true);
                    xhr.send();
                    xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4 && xhr.status == 200) {
                            var moziidcount = JSON.parse(xhr.responseText);
                            var fejlec = '<tr>';
                            for (var key in tabla[0]) {
                                fejlec += `<th>` + key + '</th>';
                            }
                            fejlec += '</tr>';
                            var sorok = '';
                            for (var i = 0; i < tabla.length; i++) {
                                let szam = moziidcount.filter(m => m.moziid == tabla[i].id);
                                sorok += `<tr title="${szam.length > 0 ? szam[0].count : 0}">`
                                for (var k in tabla[i]) {
                                    sorok += '<td>' + tabla[i][k] + '</td>';
                                }
                                sorok += '</tr>';
                                
                            }
                            $(`#${tablehead}`).html(fejlec);
                            $(`#${tablebody}`).html(sorok);
                            resolve();
                        }
                    }
                } else {
                    var fejlec = '<tr>';
                    for (var key in tabla[0]) {
                        fejlec += `<th>` + key + '</th>';
                    }
                    fejlec += '</tr>';
                    var sorok = '';
                    for (var i = 0; i < tabla.length; i++) {
                        sorok += `<tr>`;
                        for (var k in tabla[i]) {
                            sorok += '<td>' + tabla[i][k] + '</td>';
                        }
                        sorok += '</tr>';
                    }
                    $(`#${tablehead}`).html(fejlec);
                    $(`#${tablebody}`).html(sorok);
                    resolve();
                }
            }
        };
    });
}
<!DOCTYPE html>
<html lang="hu">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="index.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/2.2.2/css/dataTables.dataTables.css" />
    <script src="https://cdn.datatables.net/2.2.2/js/dataTables.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <title></title>
    <style>
        nav a {
            cursor: pointer;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand navbar-light bg-light mb-2">
        <div class="nav navbar-nav">
            <a class="nav-item nav-link" onclick="load('1.html')"></a>
            <a class="nav-item nav-link" onclick="load('2.html')"></a>
            <a class="nav-item nav-link" onclick="load('3.html')"></a>
        </div>
    </nav>
    <div id="content" ures=true>
    </div>

</body>
</html>

<div class="row col-12 justify-content-center" style="height: calc(100vh - 100px);">
    <div class="col-lg-5 h-100 mb-5" style="overflow: auto;">
        <h2 id="tablazatCim0" class="tablazatCim"></h2>
        <table id="tablazat0" class="table table-striped table-bordered table-hover table-responsive-xs">
            <thead id="tablazatHead0"></thead>
            <tbody id="tablazatBody0"></tbody>
        </table>
    </div>
    <div class="col-lg-5 h-100 mb-5" style="overflow: auto;">
        <h2 id="tablazatCim1" class="tablazatCim"></h2>
        <table id="tablazat1" class="table table-striped table-bordered table-hover table-responsive-xs">
            <thead id="tablazatHead1"></thead>
            <tbody id="tablazatBody1"></tbody>
        </table>
    </div>
</div>
<script>
    var xhrTablak = new XMLHttpRequest();
    xhrTablak.open('GET', '/get_tablak', true);
    xhrTablak.send();
    xhrTablak.onreadystatechange = function() {
        if (xhrTablak.readyState == 4 && xhrTablak.status == 200) {
            var tablak = JSON.parse(xhrTablak.responseText);
            tablaRekurziv(0, tablak);
        }
    };

    function tablaRekurziv(i, tablak) {
        if (i < tablak.length) {
            $("#tablazatCim" + i).text(tablak[i].Tables_in_vetitesek);
            fillTable('tablazatHead' + i, 'tablazatBody' + i, 'get_tablak/' + tablak[i].Tables_in_vetitesek).then((result) => {
                tablaRekurziv(i + 1, tablak);
            });
        }
    } 
</script>

<div class="row col-12 justify-content-center" style="height: calc(100vh - 100px);">
    <div class="col-auto h-100" style="overflow: auto;">
        <table class="table table-striped table-bordered table-hover table-responsive-sm">
            <thead id="tablazatHead"></thead>
            <tbody id="tablazatBody"></tbody>
        </table>
    </div>
</div>
<script>
    fillTable('tablazatHead', 'tablazatBody', 'get_szinkron_tipusonkent');
</script>

<div class="row col-12" style="height: calc(100vh - 100px);">
    <div class="col-auto h-100">
        <h2 class="">!</h2>
        <select id="selectMozi"></select>
    </div>
    <div class="col-auto h-100" style="overflow: auto;">
        <h2 class=""></h2>
        <table class="table table-striped table-bordered table-hover table-responsive-sm">
            <thead id="tablazatHead"></thead>
            <tbody id="tablazatBody"></tbody>
        </table>
    </div>
</div>
<script>
    var xhrVaros = new XMLHttpRequest();
    xhrVaros.open('GET', '/get_tablak/tabla_name', true);
    xhrVaros.send();
    xhrVaros.onreadystatechange = function() {
        if (xhrVaros.readyState == 4 && xhrVaros.status == 200) {
            var mozik = JSON.parse(xhrVaros.responseText);
            var opciok = '<option></option>';
            mozik.forEach(d => {
                opciok += `<option value=""</option>`;
            });
            $('#selectMozi').html(opciok);
        }
    };
    $('#selectMozi').change(function() {
        const moziid = $('#selectMozi').val();
        fillTable('tablazatHead', 'tablazatBody', '/get_table_name/' + moziid);
    });
</script>

TOP 10 ซื้อหวยออนไลน์เว็บไหนดี 2568 รีวิว 10 เว็บแทงหวย จ่ายจริง เชื่อถือได้

ซื้อหวยออนไลน์ ถูกกฎหมาย ซื้อหวยออนไลน์ เว็บไหนดี 2568 ซื้อหวยออนไลน์ แทงหวยออนไลน์ ซื้อหวยออนไลน์ 2 ตัว ซื้อหวยออนไลน์ กองสลาก ซื้อหวยออนไลน์ เว็บ ซื้อหวยออนไลน์เว็บไหนดี pantip แทงหวยออนไลน์ แทงหวยออนไลน์เว็บไหนดี

✅ แทงหวยคลิ้ก https://citly.me/en/px1tW

แนะนำ SBO2UPOP1 เว็บแทงหวยออนไลน์ที่ดีที่สุดในไทย ซื้อหวยออนไลน์ บาทละ 1200 มีบริการหวยครบวงจรทั้งหวยรัฐบาลไทย, หวยลาว, หวยฮานอย, หวยยี่กี, หวยหุ้น, หวยมาเลย์, หวยใต้ดิน, หวยออมสิน, และหวย ธ.ก.ส.

หวยเยอะ , หวยรัฐบาล , หวยลาว , หวยฮานอย , ยี่กี , มาเลย์ , เว็บหวยมาเเรง 2023 , สมัครสมาชิกหวยหุ้น เว็บหวยรวย , หวยโฮจิมินห์ , หวยลาวภาคี , หวยลาวมิตรภาพ , หวยลาวสำพันธ์ , หวยยี่กีได้ง่าย , หวยยี่กีกี่บาท , กลุ่มหวยยี่กี , เว็บหวยยี่กี , ซื้อหวยยี่กี , หวยยี่กีไม่โกง , หวยยี่กียิงเลข , หวยยี่รอบเร็ว , , เว็บหวยเว็บไหนจ่ายจริงบ้างครับ เว็บหวย ออกหวย , หวยดีไหม , เลข 2 ตัว , เว็บซื้อหวย หวยรัฐบาล , แทงหวย ซื้อหวยออนไลน์ , หวยไทย , หวยสด ,ซื้อหวย ขั้นต่ำ 1บาท , หวยออนไลน์ จ่ายเท่าไร , หวยมาเเรง , เว็บซื้อหวย หวยเปิดใหม่ , มักหวย หวยดี แทงหวย ใต้ดิน , หวยลาว ซื้อหวยลาว , ซื้อหวย 3 ตัวบน , สมัครหวย สมัครแทงหวยออนไลน์ , ซื้อหวยหุ้น ,ซื้อหวยรัฐบาล,ซื้อหวยกับเราไม่ยากเลย,ซื้อหวยผ่านเเอพ ,มีหวยมากมาย ซื้อหวยได้ที่ไหน , สมัครซื้อหวย , หวยออนไลน์ 24 ชั่วโมง, ซื้อหวยออนไลน์ ที่ไหนดี, เว็บหวย ดีที่สุด, ฮานอยพิเศษ, เล่นหวยสด, หวยลาว, ฮานอยVIP, แนวทางหวยหุ้น รูปเเบบหวยออนไลน์, ตรวจหวย, เว็บหวยออนไลน์, สมัครซื้อหวยง่ายๆ, ยี่กี, หวยไทย, เว็บหวย, หวยฮานอย หวยมาเลย์, ซื้อหวยได้ที่ไหน, ฮานอยวีไอพี, หวยรัฐบาล, หวยยี่กี, หวยสด, หวยลาว, มาเลย์, เว็บหวยจ่ายไม่อั่น ซื้อหวย, หวยเล่นง่าย, สมัครซื้อหวย, และเเนวทางหวย, บาทละ1200 , บาทละ1200 เป็นหนึ่งใน เว็บหวย ที่ให้บริการผ่านทางออนไลน์

popstate event triggered once

$('.Nav1').click(function() {
    history.pushState(true, '', '/home');
});

$('.Nav2').click(function() {
    history.pushState(true, '', '/gallery');
});

$('.Nav3').click(function() {
    history.pushState(true, '', '/blogs');
});

$('.Nav4').click(function() {
    history.pushState(true, '', '/memes');
});

$('.Nav5').click(function() {
    history.pushState(true, '', '/profile');
});


$(window).on('popstate', function(e) {
    let state = e.originalEvent.state;
    if(state){
        const path = window.location.pathname.replace(/^/+|/+$/g, '');
        alert(path)
    }else{
        $('.Nav1').click()
    }
});

On that scenario, the popstate triggered perfectly and triggered again if you go back until there’s no pushState().

But if you modify the popstate event like this:

$(window).on('popstate', function(e) {
    let state = e.originalEvent.state;
    if (state) {
        const path = window.location.pathname.replace(/^/+|/+$/g, '');
        if (path == 'home') {
            $('.Nav1').click();
        } else if (path == 'gallery') {
            $('.Nav2').click();
        } else if (path == 'blogs') {
            $('.Nav3').click()
        } else if (path == 'memes') {
            $('.Nav4').click()
        } else if (path == 'profile') {
            $('.Nav5').click();
        }
    } else {
        $('.Nav1').click()
    }
});

The popstate run once. After the second back, it will close the entire window or close the site.

I have 5 navigations, if you click the Profile (class=”.Nav5″), then click Memes (class=’.Nav4′), then if you click back button or swipe back. The site switch to go on Profile. Because of if(path == 'profile'). However, if you go back again, it will close the site, Instead it go back to “Home Page”. (Triggered the else statement because the state is now null.

Expectations

Case 1:

Gallery > Blogs > Profile

First Back = Blogs

Second Back = (instead of ‘Gallery’, it goes Home immediately

Third back = Close site or go back to previous site.

Case 2:

Profile

First Back = Home

Second Back = Close Site

Case 3:

Profile > Gallery > Blogs > Gallery > Memes > Profile

First Back = Memes

Second Back = Home (immediately)

Third Back = Close

REALITY

The popstate trigger once

The second back, closed the window immediately even you click more navigations.

How to code a form with JS to let visitor input phone number for Glia chatbot?

I have been working with a client who is using an existing chatbot provider (Glia). They already have a functional chatbot on the site, but the client also wants a chat widget on a particular page that will have the same functionality, but appear as a row of buttons.

The buttons are appearing as “unavailable” on initial page load, but they do show as working after a page refresh. Trying to troubleshoot that, and noticed that the phone number button needs some extra JS according to the Glia folks:

“You will also need to modify the phone section of the JavaScript to dynamically gather the visitor’s phone number, either from the member accounts or via a form on your website.”

Here’s the “phone section of the JS” as far as I can tell below (this was the code Glia has in their docs)

I am stuck as to do where it says: Read the visitor’s phone number from a separate UI element or from another information source.

Does anyone have any advice on how to modify this function to gather the visitor’s phone number in a form?

// Queue upon button click
mediaButton.addEventListener('click', function() {

if (buttonMedium === 'phone') {

// Read the visitor's phone number from a separate UI element or from

// another information source.

var visitorPhoneNumber = '+11111111111';

salemove

.queueForEngagement(buttonMedium, {

queueId: queueId,

phoneNumber: visitorPhoneNumber

})

.catch(showFailedToQueueView);

} else {

salemove

.queueForEngagement(buttonMedium, {queueId: queueId})

.catch(showFailedToQueueView);

The chatbot that is embedded throughout the site using Glia’s SDK DOES have a working UI to add a phone number. I would think that using the same SDK JS would enable the same functionality, but that doesn’t seem to be the case.

Throughout the whole project Glia has tended to give pretty cryptic instructions which could be because they are trying to get us to just give up and have them do this for WAY more money. So, client is trying to save $$$ and I am learning a lot, just not sure how to implement a feature like this. Any advice welcome! Thanks!

enter image description here

How to monitor hidden element text changes and simulate paste into Quill editor in Gemini AI interface?

I’m trying to create a userscript that monitors text changes in a visually hidden element on Google’s Gemini AI interface and automatically pastes that text into the Quill editor input area.

What I’m trying to achieve:

  1. Monitor text changes in an element with class h1.cdk-visually-hidden on https://gemini.google.com/ or https://gemini.google.com/app/
  2. When text changes are detected, simulate a human paste operation to copy that text (including multiline formatting) into the Quill editor (element with class .ql-editor)

Current issue:

When I update the hidden element with multiline text, the line breaks aren’t preserved correctly when inserted into the target Quill editor. I believe this is because I’m not properly simulating how a human would paste text.

My current approach:

I’ve tried directly setting the innerHTML of the target element, but this doesn’t trigger Quill’s native handling of pasted content:

function insertTextToInputArea(text) {
    const inputDiv = document.querySelector('.ql-editor');
    if (!inputDiv) return false;
    
    // This approach doesn't preserve multiline formatting correctly
    const formattedText = text.split('n').map(line =>
        line.trim() ? line : ''
    ).join('');
    
    inputDiv.innerHTML = '' + formattedText + '';
    
    // Trigger events
    const event = new Event('input', { bubbles: true });
    inputDiv.dispatchEvent(event);
}

What I’ve tried:

  • Setting innerHTML directly with paragraph tags
  • Using document.execCommand(‘insertText’)
  • Creating a ClipboardEvent with the text data

I believe I need to properly simulate a paste operation that will trigger Quill’s native paste handling. The target element is not a standard textarea but a contenteditable div:

How can I prevent the images from reloading when state changes in this React ImageStrip component?

I am trying to write an image strip style component, using React, that shows an array of img elements. When an img is clicked on, I want it to be set as the selected item and change the border color.

I’m facing an issue – when I click on an img, it causes all of the img elements to re-download their images.

I’ve put together this demo that shows what I’m talking about. The URLs are sample images from Lorem Picsum and will randomly generate an image upon loading. So it’s easy to see that when you click one, they all change.

How can I prevent this?

import * as React from 'react';

import ImageStrip from './ImageStrip';

function App() {
  const [selected, setSelected] = React.useState('');

  function handleClick(url: string) {
    setSelected(url);
  }

  const urlsCallback = React.useCallback(() => {
    const randomNumbers = Array.from({ length: 5 }, () =>
      Math.floor(Math.random() * 100)
    ).map((m) => Number(m));

    return randomNumbers.map((m) => `https://picsum.photos/100?random=${m}`);
  }, []);

  const urls = urlsCallback();

  return (
    <>
      <div>
        <p>selected url: {selected}</p>
      </div>
      <div>
        <ImageStrip urls={urls} selectedUrl={selected} onClick={handleClick} />
      </div>
    </>
  );
}

export default App;

https://stackblitz.com/edit/vitejs-vite-s5cxkc4k?file=src%2FApp.tsx

Custom dialog not showing info icon

Hi I am using this JS code but I am not able to view the info “ui-icon-info” icon can someone help me.

const summary = "Summary text";
const info = "Info text";
const act = "Act text";
const title = "Title";


$(document).ready(function() {
  $('<div id="custom-alert" >' + '<br><b>' + summary + '</b><br><br>' + info + '<br><br>' + act + '</div>').appendTo('body');
  $('#custom-alert').dialog({
    title: title,
    modal: true,
    width: 600,
    height: 320,
    icon: "ui-icon-info",
    closeText: '',
    buttons: {
      "OK": function() {
        $(this).dialog('destroy').remove()
      }
    }
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.14.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.14.1/themes/base/jquery-ui.css" />

Merging Base 64 pdfs into one pdf Ionic Angular [closed]

I am trying to achieve something that I have a offline online functionallity
while user is offline everything is fetched from sqlite and stored in it when i am Online the data is synced in the online data base now i have a form with ability to upload additional Documents such as pdf in the end it’s report is formed in form of pdf includinf the attached PDFs for online it can work fine. where user want to see attached document he click on view pdf he sees behind it there is a url that fetches the pdf from the backend.But for the offline i can’t do that and it is must for me the offline stuff So client demands are that the pdfs should be merged but not view i said ok but how will merge all the base 64 attached pdfs into one along the form data
and to work it offline also this is very crucial to me

Only able to do Online but not accurate

Add i tag in HTML using JavaScript?

I try to add <i> tag in Html using JS. But JS is not appending this tag.

Actually the <i> tag is a Font-Awesome icon.
Font Awesome Script tag has already been inserted in HTML head tag.

// Add side navbar
let left_navbarList = [
    {
        name: "Home",
        item_Class: "fa-solid fa -house",
    },

    {
        name: "Today",
        item_Class: "fa-light fa-calendar-days",
    },

    {
        name: "Upcoming",
        item_Class: "fa-regular fa-angle-up",
    },

    {
        name: "Complete",
        item_Class: "fa-regular fa-flag",
    },

    {
        name: "Setting",
        item_Class: "fa-regular fa-gears",
    },
]

let left_nabar = document.querySelector(".left-navbar-list");
console.log(left_nabar);

const div = document.createElement('div')
div.className = "border-white border-solid rounded-3xl pl-3.5 p-1.5 bg-[#3D404A]"
const i_tag = document.createElement('i');
i_tag.className = left_navbarList[0].item_Class;
div.appendChild(i_tag);
div.innerText = left_navbarList[0].name;
left_nabar.append(div);
<div class="left-navbar-list"></div>

I want insert a icon in div tag. What I do to handle this problem?

dmn-js integration in existing Vue 2 project causes lezer-feel and chokidar errors

I’m trying to use dmn-js in my Vue 2 project. Initially, I created a fresh Vue project just to use this library and got it working the way I wanted. Now, I’m trying to copy the components and pages into my existing project to use them there. However, I keep getting the following error:

This dependency was not found:

  • lezer-feel in ./node_modules/@bpmn-io/feel-lint/dist/index.esm.js, ./node_modules/lang-feel/dist/index.js To install it, you can run: npm
    install –save lezer-feel

Error from chokidar (C:): Error: EBUSY: resource busy or locked,
lstat ‘C:DumpStack.log.tmp’

Even though I installed lezer-feel and added the following code block to vue.config.js, the error is not resolved:

devServer: {
  watchOptions: {
    ignored: [
      '**/node_modules',
      'C:/hiberfil.sys'
    ]
  }
}

How to clear validation error messages when I open modal editor for the second time?

In Laravel 12 / vuejs 3 app I use modal form with validation in edit and insert mode.

Problem is that when user clicks on edit button to open the model form and close it (even without editing/saving it)
and next click on add button to create a new item the modal form is opened with 2 validation error messages(Not required)

Code for add button is in vue file :

<el-button type="primary" @click="openEdit(newModel, form)">Add Item</el-button>

export default {
    components: {RegionCreateDialog, ModelTable},
    mixins: [model],
    data() {
        return {
            ...
            newModel: {
                locations: [],
                location_id: null,
            }
        }
    },

Method openEdit is in common.js file, which methods are used in many editors:

methods: {
    openEdit(model, theForm) {
        console.log('openEdit model::', model)
        console.log('openEdit theForm::', theForm)

        // if (model) {
        this.form = { ...model };
        // }
        if (theForm) {
            theForm.errors = {};  // No errors - but I still have validation error messages

            // If to uncomment line below I got error :  Uncaught TypeError: Cannot read properties of undefined (reading 'clean')
            // theForm.$validator.clean();


            // If to uncomment line below I got error :  Uncaught TypeError: theForm.errors.clear is not a function
            // theForm.errors.clear();


            const initialState = {
                locations: [],
                location_id: null,
            }
            Object.assign(theForm, initialState); // No errors - but I still have validation error messages

            console.log('CLEARING ::')

        }

        this.showEditForm = true;
    },
    ...
}

I try to pass new model with empty values newModel and the form form and try to clear validation error messages – but no methods working, some raises
errors (I show in the code above)…

How to clear them correctly ?

How to upload excel sheet in a webpage by Java Script and after upload the values should fetch to Tables in website

have to create a website for graphical representation (java script)

  1. first have upload the excel file with values in webpage
  2. second load into website
  3. third after loading excel sheet values it should reflect in tables in website in every pages

is anyone can help me with it

database we have azure.

I tried creating uploading button and files getting saved but it does not fetch to next page tables

REACT Why it won’t react the next line? – Await Axios.post

UPDATE: I removed async/await and it’s now working as I expect.
However I don’t know how I can use the async/await now with this code of mine. If you have suggestions on how I should do it, It’d be appreciated.

After posting, (I checked the data base and the data saves without any problem.) My goal is to send a ‘success’ dialog after the post is successful but it doesnt seem to reach the succeeding line of codes. Please help. PS sorry for how I write my code. I’m a newbie

import axios from "axios";
import { useNavigate } from "react-router";
import { motion } from "motion/react";
import { useState, useEffect } from "react";
const GameOverForm = (props) => {
  const [isPostSuccess, setPostSuccess] = useState(false);
  const nav = useNavigate();
  const handleSubmit = async (e) => {
    e.preventDefault();
    const formData = {
      playerName: e.target.playerName.value,
      score: e.target.score.value,
    };
    try {
      console.log("before submit");
      await axios.post("http://localhost:3000/submit", formData); // This line will push through 
      console.log("after submit"); //but the succeeding lines wont be reached.
      setPostSuccess(true);
      console.log("after setPostSuccess");
    } catch (err) {
      console.log("Error", err);
    }
  };

  useEffect(() => {
    if (isPostSuccess) closeThisDialog();
  }, [isPostSuccess]);

  const closeThisDialog = () => {
    nav("/");
  };

  return (
    <>
      <form
        className="flex flex-col gap-2 items-center my-3"
        method="POST"
        onSubmit={handleSubmit}
      >
        <input type="hidden" value={props.score} name="score" />
        <input
          name="playerName"
          type="text"
          id="input"
          className="rounded-2xl h-8 border-2 border-green-800 ring-1 ring-green-200 px-2 placeholder:text-center"
          placeholder="Enter Your Name"
          required
        />
        <input type="submit" className="w-1/3 h-7 border-2 rounded-2xl" />

        {isPostSuccess && (
          <motion.p
            className="fixed top-1/2 -translate-y-1/2 w-full left-0 text-2xl"
            initial={{ opacity: 0 }}
            animate={{ opacity: 1 }}
            transition={{ duration: 1 }}
          >
            Success!
          </motion.p>
        )}
      </form>
    </>
  );
};
export default GameOverForm;

I tried to console log to double check what’s really going on and I confirmed that after the AXIOS post, it would never reach the next line of codes.

The player flickers when hovering over a thumbnail

I’m creating a section on a website that contains two columns. On the left side, there’s a video with three thumbnails below it. When hovering over one of the thumbnails, the corresponding video should play.

The problem is that when hovering over a thumbnail, the video player flickers for a moment, creating an annoying visual effect.

this is my code:

  <!-- Seccion 2 -->
         <section class="info-section">
            <div class="info-container">
              <!-- Columna 1: video -->
              <div class="info-video">
                <video id="mainVideo" controls loop>
                  <source src="vid/vid1.mp4" type="video/mp4">
                  Tu navegador no soporta el video.
                </video>
                 
                
                
              </div>
              
              <div class="miniaturas">
                <video class="miniatura" muted loop src="vid/vid1.mp4"></video>
                <video class="miniatura" muted loop src="vid/vid2.MP4"></video>
                <video class="miniatura" muted loop src="vid/vid3.MP4"></video>
              </div>
               
              
              <!-- javascript video1 -->
              <script>
                const mainVideo = document.getElementById("mainVideo");
                const miniaturas = document.querySelectorAll(".miniatura");
            
                // Reproduce el video principal al hacer hover
                mainVideo.addEventListener("mouseenter", () => {
                  mainVideo.play();
                });
               
                // Al hacer hover en una miniatura, cambia el video principal
                miniaturas.forEach((miniatura) => {
                  miniatura.addEventListener("mouseenter", () => {
                    mainVideo.src = miniatura.src;
                    mainVideo.load();
                    mainVideo.play();
                  });
                });
              </script>
            
          
              <!-- Columna 2: Texto -->
              <div class="info-text">
                <h2>Title</h2>
                <p>main text.</p>
                <a href="curso.html" class="btn-info">Ver Cursos</a>
              </div>
            </div>
          </section>
        <!-- Style seccion 2 -->
          <style>
            .info-section {
            padding: 80px 40px;
            background-color: #f0f0f0;
            }

            .info-container {
            display: flex;
            position: relative;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            max-width: 1200px;
            margin: 0 auto;
            gap: 40px;
            }

            .info-video video {
            width: 100%;
            max-width: 500px;
            height: 450px;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            }

            .miniaturas {
              position: absolute;
              top: 103%;
              left: 13%;
              display: flex;
              justify-content: center;
              gap: 10px;
            }

            .miniatura {
              width: 100px;
              height: 60px;
              cursor: pointer;
              object-fit: cover;
              border: 2px;
              border-radius: 10px;
              transition: transform 0.2s;
            }

            .miniatura:hover {
              transform: scale(1.05);
              border-color: #333;
            }
            


            .info-text {
            max-width: 500px;
            }

            .info-text h2 {
            font-size: 2rem;
            margin-bottom: 20px;
            color: #333;
            }

            .info-text p {
            font-size: 1.1rem;
            margin-bottom: 20px;
            color: #555;
            }

            .btn-info {
            display: inline-block;
            padding: 10px 20px;
            background-color: #222;
            color: white;
            text-decoration: none;
            border-radius: 6px;
            font-weight: bold;
            transition: background-color 0.3s ease;
            }

            .columna2 button:hover {
            background-color: #0056b3;
            }

          </style>