sveltefire icon indicating copy to clipboard operation
sveltefire copied to clipboard

docStore returns undefined

Open NielAgi opened this issue 11 months ago • 1 comments

export const db = getFirestore();

const userData = docStore(db, `users/rNvXG7F...KyJw1`);
console.log($userData);
const userData = docStore(db, `users/${$user?.uid}`);
console.log($userData);

Both examples log undefined. Has there been an update that broke docStore or am I just unbelievable stupid?

NielAgi avatar Feb 29 '24 16:02 NielAgi

docstore will initially return undefined as its fetching, so you'll have to do a if check.

<script>
const userData = docStore(db, `users/rNvXG7F...KyJw1`);
</script>

{#if $userData !== undefined}
{userData.ref}
{:else}
<p>Loading... </p>
{/if}

akbor avatar Jun 07 '24 12:06 akbor