#routeLoader problem when navigating

23 messages · Page 1 of 1 (latest)

wraith thorn
#

this is the code:


export const useGetUserProfile = routeLoader$<UserProfile>(
  async (requestEvent) => {
    try {
      const cookie = requestEvent.cookie.get("user")?.json<{ token: string }>();
      if (cookie?.token) {
        const resData = await fetch(
          "http://backend:8000/api/user/get/profile",
          {
            method: "GET",
            headers: {
              "Content-Type": "application/json",
              Authorization: `Bearer ${cookie.token}`,
            },
          }
        );
        const res = await resData.json();
        console.log(res.data, "data requested");
        return res.data;
      } else {
        throw new Error("no token available");
      }
    } catch (err) {
      console.log("Error useUserProfile ", err);
    }
  }
);
#

and i have the readonly signal inside the template to see what it contains in client

#
     <div class="flex !h-full w-2/5 flex-col items-center justify-center gap-10">
          <div class="flex h-full w-full flex-col items-center justify-center">
            {JSON.stringify(userProfile.value)}
#

i will upload the video showing the problem

#

when i log in i have a fresh db idk why i still have something inside the client...

at the end of the video ull see from the console log from the qwik backed

thorn sphinx
#

if I understand correctly you have multiple answers from the same routeloader giving old info? You should look at your network tab and see when the requests fire and what the cache headers are

wraith thorn
#

no no

#

so when i look into the logs qwik server has the data corectly

#

but the client dosent

#

it s like 1 step behind

#

i can make another video to show u the logs also

#

if u want

#

and every time i navigate i can show the logs so u can idk figure it out

thorn sphinx
#

no videos please

#

so when you call the routeloader, it shows the correct data on the server (via console log) but it shows the old data in the client? Try debugging the client

wraith thorn
#

yes

#

but i dont understand why is that happening

#

in qwik server i have 1 thing and in client i have another thing

#

what can i do i {} only show the data in the client

#

what debuggin can i do

wraith thorn
#

i think it s the cahing

#

yep