title: ERROR Unexpected end of JSON , input Unexpected end of JSON input
body: <p>I'm getting two errors when I submit form in edit mode. </p>
  
  <p><strong>Unexpected end of JSON</strong></p>
  
  <p><strong>input Unexpected end of JSON input</strong></p>
  
  <p>Update works fine and save values in database just I can see this message in console and route redirect after submit doesn't work. This is code service and components file.</p>
  
  <p><strong>threat.service.ts</strong></p>
  
  <pre><code>updateThreat(threat: Threat): Observable&lt;Threat&gt; {
      var requestOptions = this.authService.requestOptionsWithToken();
      return this.http.put(this.serviceUrl + 'api/threat', threat, requestOptions)
          .map(extractData)
          .catch(handleError);
  }
  
  public extractData(res: any) {
      return res.json() || [];
  }
  
  public handleError(error: Response | any) {
      let errMsg: string;
      if (error instanceof Response) {
          const body = error.json() || '';
          const err = body.error || JSON.stringify(body);
          errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
      } else {
          errMsg = error.message ? error.message : error.toString();
      }
      console.error(errMsg);
      return Observable.throw(errMsg);
  }
  </code></pre>
  
  <p><strong>add-edit-threat-component.ts</strong></p>
  
  <pre><code>import { Component, Inject, OnInit } from '@angular/core';
  import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
  import { Router, ActivatedRoute } from '@angular/router';
  
  import { Threat } from '../../../../models/threat.model';
  import { ThreatService } from '../../../../services/threat.service';
  import { ThreatComponent } from '../threat/threat.component';
  
  @Component({
  selector: 'app-add-edit-threat',
  templateUrl: './add-edit-threat.component.html',
  styleUrls: ['./add-edit-threat.component.css']
  })
  
  export class AddEditThreatComponent implements OnInit {
  
  threatCategories: any[];
  threatForm: FormGroup;
  
  id: number;
  editMode: boolean = false;
  
  typeOfThreat = [
      { value: 1, name: 'Security' },
      { value: 2, name: 'Safety' }
  ];
  
  originOfThreat = [
      { value: 1, name: 'Internal' },
      { value: 2, name: 'External' },
      { value: 3, name: 'Both' }
  ];
  
  constructor(private fb: FormBuilder,
      private threatService: ThreatService,
      private router: Router,
      private route: ActivatedRoute) {
  
      if (this.route.snapshot.params["id"]) {
          this.id = +this.route.snapshot.params["id"];
      }
  
      this.threatForm = this.fb.group({
          threatId: 0, 
          name: ['', [Validators.required]],
          category: ['', [Validators.required]],
          description: [''],
          internalExternal: [1, Validators.required],
          securitySafety: [3, Validators.required],
          avoidRisk: [false],
          shareRisk: [false],
          reduceRisk: [false],
          acceptRisk: [false],
          confidenciality: [false],
          integrity: [false],
          availability: [false],
          authenticity: [false],
      })
  }
  
  ngOnInit() {
      this.onGetThreatsCategory();
  
      if (this.id &gt; 0) {
          this.editMode = true;
          this.threatService.getThreat(this.id)
              .subscribe(data =&gt; this.threatForm.patchValue(data))
      }
  }
  
  onGetThreatsCategory() {
      this.threatService.getThreatCategory()
          .subscribe(
          response =&gt; {
              this.threatCategories = response.items;
          });
  }
  
  onSubmit() {
      if (!this.threatForm.valid) {
          return
      }
  
      if (!this.editMode) {
          this.threatService.createThreat(this.threatForm.value)
              .subscribe((data) =&gt; {
                  this.router.navigate(['/threat']);
                  console.log(this.threatForm);
              })
      }
      else if (this.editMode) {
          this.threatService.updateThreat(this.threatForm.value)
              .subscribe((data) =&gt; {
                  this.router.navigate(['/threat']);
                  console.log(this.threatForm);
              })
      }
  }
   }
  </code></pre>