'Express sendFile() and page refresh

I have a simple express server with paths /login which returns Login.html and /play which returns game.html using res.sendFile().

When I go to the end points directly on Crome, I can display the mentioned pages accordingly, however, I want to go to /play from a button in login.html. I created a function using fetch api and added that to the button as a click event listener.

The problem is that, everything works fine, except the browser is stuck in login.html. It does not refresh to game.html.

The request the button triggers receives a 304 code.

The desired functionality can be achieved setting windows.location.href to ‘…/play’, but I don’t understand why it doesn’t work the way mentioned above.

It works fine when those endpoints are hit separately but why not when /play is triggered from a button in login.html.

I can later add the code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source