sveltefire
sveltefire copied to clipboard
docStore returns undefined
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?
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}