Uncaught (in promise): Error: Cannot read property of undefined
<p>Component take user from service with params</p>

<pre><code>@Component({
    selector: 'users',
    providers: [UserService],
    template: `
    &lt;p&gt;{{user.id}}&lt;/p&gt;
`
})
export class UserPageComponent implements OnInit  {
    constructor(
        private userService: UserService,
        private route: ActivatedRoute
    ) {};

    ngOnInit(): void {
        this.route.params.forEach((params: Params) =&gt; {
            let id = +params['id'];
            this.userService.getUser(id)
                .then(user =&gt; {console.log(user.id);this.user = user})
        });
    }
</code></pre>

<p>Service :</p>

<pre><code>@Injectable()
export class UserService {
    private postUrl = 'http://127.0.0.1:8000/user-detail/';  // URL to web api
    constructor(private http: Http) {
    }

    getUser(id: number): Promise&lt;User&gt; {

        return this.http.get(this.postUrl+id)
            .toPromise()
            .then(response =&gt; response.json() as User)
            .catch(this.handleError);

    };
</code></pre>

<p>And I get Error <code>Uncaught (in promise): Error: Error in ./UserPageComponent class UserPageComponent - inline template:1:7 caused by: Cannot read property 'id' of undefined</code></p>

<p>It looks as if the service does not send the promise, although it should.
How to solve this proble?</p>