Problem with my express toy app

Hi there people. I'm trying to find out why when I try to access a page after sending a form , the given page won't load any stylesheets. When I access the route directly it works normally I have found that when I comment the writeDB() call in the controller, everything solves itself. Any idea why is that?
I'll add the repo. I'm kinda stuck and have tried everything.
https://github.com/juandevac/express-session
GitHub
GitHub - juandevac/express-session: I'm trying to solve some bug.
I'm trying to solve some bug. Contribute to juandevac/express-session development by creating an account on GitHub.
Solution:
when you save the new user to the json file
Jump to solution
26 Replies
Lopen
Lopen•15mo ago
Why are you using express for this?
Roncan
RoncanOP•15mo ago
Well, it's the tool I'm learning. I'm in a bootcamp 🤠
Matvey
Matvey•15mo ago
I cloned your repo and it worked fine for me
Roncan
RoncanOP•15mo ago
When sending the form in "/"? May it be something in my machine?
Matvey
Matvey•15mo ago
it loaded the result.css, but it's empty
Roncan
RoncanOP•15mo ago
Well, then it isn't working. It's weird. When you comment out the writeDB() call in the route that redirects to "/", the error vanishes
Matvey
Matvey•15mo ago
what is the expected result? When i comment out writeDB(), it works the same
Roncan
RoncanOP•15mo ago
Well, the idea is to use the stylesheets in /result But they load empty And I've checked everything and they do not work.
Matvey
Matvey•15mo ago
the file is empty
Matvey
Matvey•15mo ago
you didn't put any css in result.css
Roncan
RoncanOP•15mo ago
Oh yeah, not by now. But modern-normalize should load normally
Roncan
RoncanOP•15mo ago
I just did another try and yeah, the css file are not found. When sending form and being redirected from "/" to "/result"
Roncan
RoncanOP•15mo ago
But if I reload the page from here, it just works
Roncan
RoncanOP•15mo ago
Matvey
Matvey•15mo ago
modern-normalize loads fine for me and there are no errors in the console
Roncan
RoncanOP•15mo ago
Weird, it may be my computer then. I'd like to know more about routing and stuff 😕 Have any idea how to look more into this? If not that's okay, you've helped a lot already!
Matvey
Matvey•15mo ago
what do you mean by "routing and stuff"?
Roncan
RoncanOP•15mo ago
Well, the fact that it works for you and not for me may mean that the problem isn't code related That maybe the port i'm using doesn't work with redirects and stuff And since I moved to ubuntu last week I might be doing something wrong
Matvey
Matvey•15mo ago
I think I know why this is happening
Solution
Matvey
Matvey•15mo ago
when you save the new user to the json file
Matvey
Matvey•15mo ago
the nodemon restarts your server and the browser can't load the css files because the server is restarting
Roncan
RoncanOP•15mo ago
That makes sense. That's why when I commented out that method call the code worked perfectly! The thing is how to solve it now thinkies I don't think I see anything in the code that makes nodemon restart
Matvey
Matvey•15mo ago
it's in package.json you can pass a parameter to only watch .js files
Roncan
RoncanOP•15mo ago
oh! so it's watching the json and when it changes that's why it fails? well, restarts Solved! Man thanks, it was such a silly thing
Matvey
Matvey•15mo ago
no problem
Roncan
RoncanOP•15mo ago
Six hours yesterday, I even became chatGPT chatter, finally solved
Want results from more Discord servers?
Add your server