Communicating with client: Fetch

Server
function serverResponse(req,res) {
  const response = "Hello from the server";
  res.header("Access-Control-Allow-Origin","*");
  res.send({msg:response});
}
Client
fetch("http://localhost:8000/")
 .then(response=>{return response.json();})
 .then(userCallbackFunction);

function userCallbackFunction(data) {
  console.log(data.msg);
}