title: Angular 5 HTTP get response error Property 'body' does not exist on type 'Object'
body: <p>I am working on Angular 5 with Http.</p>
  
  <p><a href="https://i.stack.imgur.com/IscpQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IscpQ.png" alt="enter image description here"></a></p>
  
  <p>Getting this error while serve the application..</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Router, ActivatedRoute, ParamMap } from '@angular/router';
  import { HttpClient } from '@angular/common/http';
  import 'rxjs/add/operator/switchMap';
  
  @Component({
   selector: 'app-post-detail',
   templateUrl: './post-detail.component.html',
   styleUrls: ['./post-detail.component.css']
  })
  export class PostDetailComponent implements OnInit {
   body: string;
   recent: {};
   constructor(
      private route: ActivatedRoute,
      private router: Router,
      private http: HttpClient,
   ) { }
  
   ngOnInit() {
     let id = this.route.snapshot.paramMap.get('id');
     let userId = this.route.snapshot.paramMap.get('userid');
     this.getUserPosts(userId);
     this.http.get('https://jsonplaceholder.typicode.com/posts/'+id)
     .subscribe((data)=&gt;{
      this.body = data.body;
     });
   }
  }
  </code></pre>
  
  <p>I dont know Why I am getting this error and I assign the type as string in the class based on the syntax.</p>
  
  <p>Response of API as below,</p>
  
  <p><a href="https://i.stack.imgur.com/diBQ8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/diBQ8.png" alt="enter image description here"></a></p>