-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
<script context="module">
export async function preload({ params }) {
const res = await this.fetch('example.com/id1234.json');
const resJSON = await res.json();
return { resJSON };
}
</script>
Then later in the code...
const queryResult = useQuery('characterData', async () => {
const data = await axios.get('example.com/id1234.json')
return data
},{refetchInterval: 30000, initialData: menuData, refetchIntervalInBackground: false, notifyOnChangeProps: ['data', 'error']})
Then...
{#if $queryResult}
{JSON.stringify($queryResult.data.characters)}
{/if}
will result in a the initial data showing for a split second and then it showing 'undefined'. What's weird is that if I just output the entire $queryResult.data it will not show undefined, but the entire object. I hope this makes sense.
EDIT: I found the issue! I needed to return { data };
instead of return data
from axios, 🤦♂️
Metadata
Metadata
Assignees
Labels
No labels