title: Angular2 HTTP POST An error occurred SyntaxError: Unexpected end of JSON input
body: <p>I have error meantime angular2 post rest data to NodeJS backend.</p>
  
  <p>I see POST is done, server is LOG correct data, but error is showing up on browser.</p>
  
  <p>An error occurred:
  SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data</p>
  
  <p>My NG2 call and service:</p>
  
  <pre><code>onSubmit(form:FormGroup) {
          let userform: FormGroup = form.value;
          console.log("userform: ", userform);
  
          if (form.valid) {
              console.log(form.value);
              this.appService.signIn(userform)  
                  .subscribe(form =&gt; console.log('subscribe: ', form))
          } else {
              console.log("Form is not VALID!"); 
          }
      }
  </code></pre>
  
  <p>SERVICE: </p>
  
  <pre><code>signIn(dataUser: Object): Observable&lt;User&gt; {
     dataUser = JSON.stringify(dataUser);
     debugger;
  
      let headers = new Headers({
          'Content-Type': 'application/json',
          'Access-Control-Allow-Origin': 'http://127.0.0.1:3005'
      });
      let options = new RequestOptions({ headers: headers });
  
      console.log("data: ", dataUser, "\nHeaders: ", headers);
  
      return this.http
          .post( this.signInUrl, dataUser, options)
          .map( (res:Response) =&gt; res.json().data || {  } as User )
          .catch(this.handleError);
  
  }
  </code></pre>
  
  <p>and nodeJS:</p>
  
  <pre><code>app.post('/login', function (req, res) {
      console.log("Recived login request!");
      console.log("Request: ", req.body);
      res.header({
          'Content-Type': 'application/json',
          'Access-Control-Allow-Origin': '*',
          'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE',
          'Accept': 'q=0.8;application/json;q=0.9'
      })
      res.end();
  });
  </code></pre>
  
  <p>In post we have: "{"username":"username","password":"password"}".</p>
  
  <p>What I'am making wrong? Please for help or solution.</p>