I am unable to query data, the same way I am querying it through an index route. I am trying to create a sidebar widget for our blog and I keep getting undefined. Does this mean that data can only be queried through routes? I was able to query it in a promise but I can't seem to get that data out of a promise. See the code below using SvelteKit's load function.
<script context="module">
import Prismic from "@prismicio/client";
import Client from "../../../utils/client";
export async function load() {
const document = await Client.query(
Prismic.Predicates.at("document.type", "blog_post")
);
return {
props: {
document,
},
};
}
</script>
<script>
export let document;
console.log(document);
</script>