title: Angular subscribe response
body: <p>Okay, I'm pretty new to Angular, so I have this little problem. So i'm following the Angular guide (<a href="https://angular.io/guide/http" rel="nofollow noreferrer">https://angular.io/guide/http</a>). So my problem is that my http-response is always undefined. In debug-tools the response is: </p>
  
  <pre><code>{"code":0,"status":"error","message":"Invalid JWT - Authentication failed!"}
  </code></pre>
  
  <p>as it should be. But when I console-log response, it always says </p>
  
  <pre><code>This should be the response???:  undefined
  </code></pre>
  
  <p>profile.component.ts</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { parse } from 'path';
  import { HttpClient } from '@angular/common/http';
  import { Router } from '@angular/router';
  import { getLocaleTimeFormat } from '@angular/common';
  import { UserService } from '../user.service';
  import { Config } from '../config';
  
  @Component({
    selector: 'app-profile',
    templateUrl: './profile.component.html',
    styleUrls: ['./profile.component.css']
  })
  
  export class ProfileComponent implements OnInit {
  
    tmp: any;
    token: any;
    tmp2: any;
    config: Config;
    constructor(private userService: UserService, private router: Router,
      private http: HttpClient) { }
  
    ngOnInit() {
  
  
      this.token = localStorage.getItem('token');
      this.tmp = this.userService.checkToken(this.token)
        .subscribe((data: Config) =&gt; this.config = {
          code: data['code'],
          message: data['message']
        });
  
      console.log("This should be the response???: ", this.config);
    }
  
  }
  </code></pre>
  
  <p>and the user.service.ts </p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Router } from '@angular/router';
  import { HttpClient, HttpResponse } from '@angular/common/http';
  import { Response } from "@angular/http";
  import { Observable } from "rxjs";
  import 'rxjs/add/operator/map';
  import { httpFactory } from '@angular/http/src/http_module';
  import { Config } from './config';
  
  @Injectable({
    providedIn: 'root'
  })
  export class UserService {
  
  
    config: Config;
    items: any;
    readonly url = 'http://localhost:82/phpangular/userSystem/src/api/userCtrl.php';
  
  
    constructor(private http: HttpClient, private router: Router) { }
  
    checkToken(token) {
     return this.http.post&lt;Config&gt;
     (this.url, {'data': 'checkToken', 'token': token});
    }
  
  
  }
  </code></pre>
  
  <p>and my interface config.ts</p>
  
  <pre><code>export interface Config {
  
      code: string;
      message: string;
  }
  </code></pre>
  
  <p>If someone would give me a pointer, I would be real glad :)</p>
  
  <p>Cheers</p>
  
  <ul>
  <li>Niko</li>
  </ul>