asbilly92
(Amy Stout)
September 18, 2021, 4:05am
1
Upon calling my h1 like: <h1> {document.data.title} </h1>
... It's rendering as [object Object] ??
** in my page it's a Key Text Field and not rich text; fyi
** as per other similar post my @prismic-dom is installed as a devDependency
Any help thank you ahead of time!
Priyanka
(Priyanka Maheshwari)
September 20, 2021, 9:11am
3
Hello Amy,
Welcome to the Prismic community Forum.
I need more information from you to solve this issue. Like:
What framework are you using?
How are you querying the Prismic document? Can you post the query here?
What is this query returning on the console in the object? Can you post the query here?
Thanks,
Priyanka
asbilly92
(Amy Stout)
September 23, 2021, 10:44pm
4
Yep! Sorry so the framework is SvelteKit
** Following this tutorial post: How to Make a Website with SvelteKit in 15 Minutes - Prismic
Actually for some reason it's returning Null and not an object now: it's a Key Text Field from Prismic on a Page Document with the API ID of title; which should end up the title inside of an h1 tag.
I just cloned the repo so it's exactly the same as on GitHub...GitHub - samlfair/svelte-tutorial: This repo is the final product of the above tutorial. It is a two-page website using Svelte and Sveltekit with content managed in Prismic.
<script context="module">
import Client from "./../../utils/client";
import PrismicDom from "prismic-dom";
export async function load({ page }) {
const { uid } = page.params;
const document = await Client.getByUID("page", uid);
return {
props: {
document,
uid,
},
};
}
</script>
Also the h1 is being called like: (once again just like the GitHub)
<h1>
{document.data.title}
</h1>
Hope this helps Thank you!
asbilly92
(Amy Stout)
September 23, 2021, 11:05pm
5
Ok it's working now... sorry I have NO idea what I did to fix it other than I unpublished the pages and made them again. When I refreshed walaa ... hope I didn't cause anyone too much time!!
Anyway happy it's working now!!
Priyanka
(Priyanka Maheshwari)
September 27, 2021, 10:28am
6
Hello @asbilly92
I am glad that it is working for you. Don't hesitate to reach out to us if you have any questions.
Thanks,
Priyanka
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
September 28, 2021, 10:28am
7
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.