In my page i call a function in the backend as soon as the page is loaded.
But this function is running twice and I can’t figure out why. What am I doing wrong?
All the code in my page is this:
import {dashstset} from 'backend/MySQL2';
$w.onReady(async function () {
let uem = 'martin.howard'
let uset=await dashstset(uem)
})
all the code in MySQL2 is this:
import mysql from "mysql"
const pool = mysql.createPool({
connectionLimit: 1000,
host: 'XXXXXXXXXXXXXXXXXXXXXXXXX',
user: 'XXXXXXXXXXXXXXXXXXXXXXXXX',
password: 'XXXXXXXXXXXXXXXXXXXXXXXXX',
});
const runQuery = (query, params = []) => {
return new Promise((resolve, reject) => {
pool.query(query, params, (error, results) => {
if (error) {
reject(error);
} else {
resolve(results);
}
});
});
};
export async function dashstset(usuario) {
console.log(0)
const setst = await runQuery("SELECT * FROM aux_db.dash_acao where user= ?", [usuario])
return setst
}
Notice the “0” is being logged twice:

