title: Can´t get response in angular from asp.net core web api
body: <p>I hope somebody can help. I´ve created a new asp.net core angular project in visual studio and a simple api method just like this:</p>
  
  <pre><code>[Produces("application/json")]
  [Route("api/Users")]
  public class UsersController : Controller
  {
      [HttpGet("[action]")]
      public async Task&lt;JsonResult&gt; CheckAPIConnection()
      {
          return Json(new { success = true }); 
      }
  </code></pre>
  
  <p>then I´ve created a new service in angular</p>
  
  <pre><code>    import { Injectable } from '@angular/core'; 
  import { Http } from '@angular/http'; 
  import { Headers, RequestOptions } from '@angular/http';
  import 'rxjs/add/operator/map'; 
  
  @Injectable() 
  export class ApiService {
      constructor(private http: Http) {
  
  }
  
  checkAPIConnection() {
      let result = this.http.get("/api/Users/CheckAPIConnection");
      let jso:any;
      result.subscribe(res =&gt; jso = res);
      console.log(jso);
      if (jso.success == true) return true;
      else return false; 
  }
  </code></pre>
  
  <p>In fiddler the request succeeds and the response is correct. But console.log tells me that "jso" is undefined. So I´ve tried to add</p>
  
  <pre><code>result.subscribe(res =&gt; jso = res.json());
  </code></pre>
  
  <p>but this does not change anything. I´ve also tried to enter "jso" with <code>jso["success"]</code> but I think the mayor problem is that jso is undefined. </p>
  
  <p>I´ve tried to search for solutions but everbody used something like <code>then()</code> instead of <code>subscribe()</code>. Am i missing some imports or so? (Sorry I´m very new to angular especially in receiving data from api) </p>