Been trying to use FaunaDB in my website, and i cant seem to figure out much, ChatGPT has helped me for the most part but it can’t help here for some reason… heres my current code:
const client = new Client({
secret: '...nope i am not gonna let someone have my key...',
});
async function RunQ(query) {
try {
// Run the query
const result = await client.query(query);
return JSON.stringify(result, null, 2);
} catch (error) {
// Handle errors
return new Error(error.message);
}
}
// here us an example function
async function CreateUser() {
const query = fql`
users.createData({
email: '[email protected]',
pass: 'pass1',
totals: {
}
})
`;
await RunQ(query);
}
<script type="module">import{Client,fql}from'https://cdn.jsdelivr.net/npm/fauna@latest/dist/browser/index.js';console.log(fql ? 'MODULE LOADED' : 'FAILED TO LOAD MODULE')</script>
<script src="./main.js"></script>
It logs ‘MODULE LOADED’, but when i run CreateUser() it errors that ‘fql not found’.
Does this have to do with the fact that it is a module? I don’t know what’s wrong and I’ve been trying to fix it for a while now, so thanks in advance!