Fetching in layout
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
I have a backend where I want to fetch the config when the user enters the site. My thought was to fetch in my layout.js file but it doesn't do anything as opposed to fetching on another page where the function does work. I want to fetch on layout though since it wraps around every other page which means the fetch will run no matter what page the user is initially on.
21 Replies
I don't get what you are asking @Masai Lion lol. Explain the issue
@Arinji I don't get what you are asking <@210245222238519296> lol. Explain the issue
Masai LionOP
i want to run code a single time when the user goes onto the site
from any page
@Masai Lion i want to run code a single time when the user goes onto the site
And do you use the response anywhere?
Or is it like analytics type, where you just make the request
@Arinji And do you use the response anywhere?
Masai LionOP
no not really
i just need my backend to set a cookie
frontend just calls it
Oh, then just make the request from your middleware
It runs on every request
@Arinji It runs on every request
Masai LionOP
preferably i want something that could just run once when the user enters instead of every request
@Masai Lion preferably i want something that could just run once when the user enters instead of every request
Thing is the layout won't rerender when the route changes, try this one sec
This will rerender on navigations
@Arinji Thing is the layout won't rerender when the route changes, try this one sec
Masai LionOP
i just want it to render once when the user comes to the website
not rendering when the route changes is preferablwe
Lionhead
if i understand, try to do it with cookies. When user opens page, save cookies
@Masai Lion i just want it to render once when the user comes to the website
Ohhhh so a modal type thing?
@Arinji Ohhhh so a modal type thing?
Masai LionOP
i make an api call to the server to set some cookies and get some config
@Masai Lion i make an api call to the server to set some cookies and get some config
Yea then do it in the layout