'Header is empty when making a fetch-api call

I am trying to generate a session ID and then send that session ID to the front end of my application in the header (I know I should use the body to do this but my prof wants us to use header so we know how to use it).

The fetch response that I get has head but its value is {}, but I'm also getting a 200 'OK' so I know it is at least connected to the front end correctly.

My backend code is this:

router.get('/sid', function (req, res) {
  res.setHeader('X-sid', getSid());
  res.send();
});

My frontend code is this:

function sessionId() {
   fetch('/wordgame/api/v1/sid').then(x => {
      console.log(x);
});


Sources

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

Source: Stack Overflow

Solution Source