Need help with calling an async function pushData() from a button onClick event
async function pushData() {
alert("wee");
console.log("pushing data");
try {
await query(`
//SQL CODE
`);
console.log("Done");
} catch (e) {
console.error("wtf");
console.log(e);
}
}
import React from "react";
export default function Dashboard() {
return (
<div>
<div>
<h2>Dashboard</h2>
</div>
<button onClick={async () => await pushData()}>SQL BUTTON</button>
</div>
);
}
The alert('wee')
works, but the await
and console.log()
are not functioning as expected.