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