title: Why isn't my function returning the proper JSON data and how can I access it?
body: <p>I'm running services to retrieve data from an API. Here is one of the services: </p>
  
  <pre><code>robotSummary(core_id, channel_name){
  const params = new HttpParams()
  
  
  var new_headers = {
    'access-token': ' '
  };
  this.access_token = sessionStorage.getItem('access-token');
  new_headers['access-token'] = this.access_token;
  
  const myObject: any = {core_id : core_id, channel_name: channel_name};
  const httpParams: HttpParamsOptions = { fromObject: myObject } as HttpParamsOptions;
  
  const options = { params: new HttpParams(httpParams), headers: new_headers };
  return this.http.get(this.baseURL + 'web_app/robot_summary/',options)
  .subscribe(
  res =&gt; console.log(res),
          )
     }
  }
  </code></pre>
  
  <p>The data shows up properly on the console, but I still can't access the individual keys: 
  <a href="https://i.stack.imgur.com/CyMbK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CyMbK.jpg" alt="console"></a></p>
  
  <p>Here is how I call it: </p>
  
  <pre><code>ngOnInit(): void{
  
    this.login.getData(this.username, this.password).subscribe((data) =&gt; {
  this.robotSummaryData = this.getRobotSummary.robotSummary(this.core_id, this.channel_name);
      console.log("robosummary"+ this.robotSummaryData)
    });
    }
  </code></pre>
  
  <p>When I call this function and assign it to a variable, it shows up on console as [object Object]. When I tried to use JSON.parse, it throws the error: type subscription is not assignable to parameter string. How can I access the data? I want to take the JSON object and save it as an Object with appropriate attributes. Thanks! </p>