I want to post username and password to my backend.
Problem is that the data doesn't reach my backend, with following code:
function register() {
  var text = '{"username":"admin1","password":"1234"}';
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "http://localhost:8087/meetmeserver/api/admin/register", true);
  xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
  xhr.send(JSON.stringify(text));
}
If I leave out the line with xhr.setRequestHeader, it reaches my backend but throwing an exception...
Does anyone now where my problem is? I really would appreciate your help. If you need more code just tell me.
 
     
    