Saaa
Saaa
SSolidJS
Created by Saaa on 6/7/2024 in #support
Create Effect not executing
the function getName is working fine and shows the name of the person with id 1 after fetching it from my database but this code doesnt log anything to console not even the debug console.log("running") i did :
import { Database } from '~/types';
import { Kysely, PostgresDialect } from 'kysely';
import pkg from 'pg';
import { createEffect, createSignal } from 'solid-js';
const { Pool } = pkg;

const dialect = new PostgresDialect({
pool: new Pool({
database: 'db',
host: 'fakehost',
user: 'user',
port: 5432,
max: 10,
ssl: true,
password: 'password123',

}),
});

const db = new Kysely<Database>({
dialect,
});

async function getName(id: number) {
const x = await db.selectFrom('person').selectAll().where("id" , "=" , id).execute();
await console.log(x[0].first_name) //does not execute or show anything
return x[0].first_name;
}

export default function Myperson() {

//getName(1) runs and log to the console 'Jhon' successfully but
const [name , setName] = createSignal('Loading...')
createEffect(() => {
(async () => {
console.log("Running") //does not execute or show anything
const nameResult = await getName(1);
setName(nameResult);
})();
});
return (
<div>
{name()}
</div>
);
}
import { Database } from '~/types';
import { Kysely, PostgresDialect } from 'kysely';
import pkg from 'pg';
import { createEffect, createSignal } from 'solid-js';
const { Pool } = pkg;

const dialect = new PostgresDialect({
pool: new Pool({
database: 'db',
host: 'fakehost',
user: 'user',
port: 5432,
max: 10,
ssl: true,
password: 'password123',

}),
});

const db = new Kysely<Database>({
dialect,
});

async function getName(id: number) {
const x = await db.selectFrom('person').selectAll().where("id" , "=" , id).execute();
await console.log(x[0].first_name) //does not execute or show anything
return x[0].first_name;
}

export default function Myperson() {

//getName(1) runs and log to the console 'Jhon' successfully but
const [name , setName] = createSignal('Loading...')
createEffect(() => {
(async () => {
console.log("Running") //does not execute or show anything
const nameResult = await getName(1);
setName(nameResult);
})();
});
return (
<div>
{name()}
</div>
);
}
16 replies
SSolidJS
Created by Saaa on 6/5/2024 in #support
How to get and set simple data or a variable in a session?
I tried settings the username and then reading it in a session in the client side in the following code but it gives an error: import { useSession } from "vinxi/http"; function getSession() { return useSession({ password: process.env.SESSION_SECRET }); } export default function Index() { const session = getSession(); session.data.user = "adam"; //set the user name const username : string = session.data.user //get the user name return ( <div> <p>Username: {username}</p> </div> ); }
4 replies
SSolidJS
Created by Saaa on 5/30/2024 in #support
Cannot read properties of null (reading 'nextSibling') ERROR in a hello world simple Solidstart web
i just added a route called docs to a brand new project in routes folder docs.mdx and inside it a text message hello world and when i enter the route it gives me this error Cannot read properties of null (reading 'nextSibling') ../../../solid-js/web/dist/dev.js createRenderEffect(() => (current = insertExpression(parent, array, current, marker, true))); return () => current; } if (hydrating) { if (!array.length) return current; if (marker === undefined) return [...parent.childNodes]; let node = array[0]; let nodes = [node]; while ((node = node.nextSibling) !== marker) nodes.push(node); return (current = nodes); } if (array.length === 0) { current = cleanChildren(parent, current, marker); if (multi) return current; } else if (currentArray) { if (current.length === 0) { appendNodes(parent, array, marker);
2 replies