# Unable to query data in a non route component

**URL:** <https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799>\
**Category:** Developing with Prismic\
**Tags:** svelte\
**Created:** [June 15, 2021, 11:04pm UTC](https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799 "2021-06-15T23:04:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![teddy\_stanowski](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/teddy_stanowski/32/1952_2.png) [@teddy\_stanowski](https://community.prismic.io/u/teddy_stanowski)\
**Post date:** [June 15, 2021, 11:04pm UTC](https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799/1 "2021-06-15T23:04:44Z")

</div>

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.

```auto
<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>

```

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [June 18, 2021, 9:05pm UTC](https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799/3 "2021-06-18T21:05:20Z")

</div>

Hello @teddy_stanowski

Thanks for posting this question to us.

You can not use `load()` function outside of the routes. It can only be used in a page or layout component. You can either fetch the data from the page or layout and pass the data as a prop to the sidebar component.

Let me know if you have any other doubts.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [June 19, 2021, 11:58pm UTC](https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799/4 "2021-06-19T23:58:14Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 3:41pm UTC](https://community.prismic.io/t/unable-to-query-data-in-a-non-route-component/5799/5 "2021-12-09T15:41:06Z")

</div>


