gmnss1917
gmnss1917
SSolidJS
Created by gmnss1917 on 9/14/2023 in #support
how to handle responses from the server on the client?
export async function logInFn(
form: FormData,
locals: Record<string, any>
): Promise<User | undefined> {
const pb = getPb(locals);
try {
const { record } = await pb
.collection("users")
.authWithPassword<User>(
form.get("username") as string,
form.get("password") as string
);
const user: User = {
id: record.id,
username: record.username,
name: record.name,
email: record.email,
avatar: record.avatar,
};
return user;
} catch (error) {
if (error instanceof ClientResponseError) {
console.error("ERROR: ", error);
throw new ServerError("Failed to authenticate", {
status: (error as ClientResponseError).status,
});
}
}
}
export async function logInFn(
form: FormData,
locals: Record<string, any>
): Promise<User | undefined> {
const pb = getPb(locals);
try {
const { record } = await pb
.collection("users")
.authWithPassword<User>(
form.get("username") as string,
form.get("password") as string
);
const user: User = {
id: record.id,
username: record.username,
name: record.name,
email: record.email,
avatar: record.avatar,
};
return user;
} catch (error) {
if (error instanceof ClientResponseError) {
console.error("ERROR: ", error);
throw new ServerError("Failed to authenticate", {
status: (error as ClientResponseError).status,
});
}
}
}
3 replies
SSolidJS
Created by gmnss1917 on 9/14/2023 in #support
how to handle responses from the server on the client?
const [loggingIn, logIn] = createServerAction$(
async (form: FormData, { locals }) => {
return await logInFn(form, locals);
}
const [loggingIn, logIn] = createServerAction$(
async (form: FormData, { locals }) => {
return await logInFn(form, locals);
}
3 replies
SSolidJS
Created by gmnss1917 on 8/31/2023 in #support
how to define event.locals type?
so, should I be using this casting it everytime or am I doing something not in an optimal way ?
3 replies
SSolidJS
Created by gmnss1917 on 8/29/2023 in #support
PocketBase Auth with Context doesn't track store
thanks for the help bruv it seems to working now !
6 replies
SSolidJS
Created by gmnss1917 on 8/29/2023 in #support
PocketBase Auth with Context doesn't track store
PS: I wrapped my Routes with the AuthProvider
6 replies
SSolidJS
Created by gmnss1917 on 7/13/2023 in #support
How to pass key into createRouteData function inside useRouteData ?
thanks for the clarification
9 replies
SSolidJS
Created by gmnss1917 on 7/13/2023 in #support
How to pass key into createRouteData function inside useRouteData ?
yeah, that kinda sucks but okay, I can rearchitect around this
9 replies
SSolidJS
Created by gmnss1917 on 7/13/2023 in #support
How to pass key into createRouteData function inside useRouteData ?
aren't these params just the url params ? I will try anyway
9 replies
SSolidJS
Created by gmnss1917 on 6/17/2023 in #support
routeData arguments
type GoalCardProps = { goalId: string, description: string, deadline: string } export function routeData() { return createRouteData(async (goalId) => { const response = await pb.collection('milestones').getFullList({ filter: parent = "${*goalId*}" }) console.log(response) let milestones: Goal[] = [] return "milestones" }) } export default function GoalCard(props: GoalCardProps) { const milestones = useRouteData<typeof routeData>() return ( <div class="text-center text-3xl"> <span><strong>{props.description}</strong></span> <span> | {props.deadline} </span> <input type="checkbox" class="checkbox" /> <button class="btn btn-square"> <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg> </button> </div> ) }
3 replies
SSolidJS
Created by gmnss1917 on 6/17/2023 in #support
routeData arguments
code in question:
3 replies