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
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.
26 Replies
Why are you using express for this?
Well, it's the tool I'm learning. I'm in a bootcamp ðŸ¤
I cloned your repo and it worked fine for me
When sending the form in "/"?
May it be something in my machine?
it loaded the
result.css
, but it's emptyWell, then it isn't working. It's weird. When you comment out the writeDB() call in the route that redirects to "/", the error vanishes
what is the expected result? When i comment out
writeDB()
, it works the sameWell, the idea is to use the stylesheets in /result
But they load empty
And I've checked everything and they do not work.
the file is empty
you didn't put any css in result.css
Oh yeah, not by now. But modern-normalize should load normally
I just did another try and yeah, the css file are not found. When sending form and being redirected from "/" to "/result"
But if I reload the page from here, it just works
modern-normalize loads fine for me and there are no errors in the console
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!
what do you mean by "routing and stuff"?
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
I think I know why this is happening
Solution
when you save the new user to the json file
the nodemon restarts your server
and the browser can't load the css files because the server is restarting
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
I don't think I see anything in the code that makes nodemon restart
it's in package.json
you can pass a parameter to only watch .js files
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
no problem
Six hours yesterday, I even became chatGPT chatter, finally solved