моя проблема состоит в том, что app я функционирует, но консоль посылает мне следующую ошибку, нужно отмечать, что app я, который является практикой, я функционирует
ExternoComponent.html:1 ОШИБКА TypeError: Cannot read property 'first_name' of undefined
и cygwin следующий
ОШИБКА in src / app / приходящий ученик / externo.component.ts (20,27): ошибка TS2339: Property 'датирует' does not exist on type 'Object'.
src/app/externo/externo.component.ts(21,28): error TS2339: Property 'data' does not exist on type 'Object'.
и правда я страдаю морской болезнью, потому что не, если это моя ошибка или браузера или моей версии углового или этого составителя это мой service
import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable() export class PeticionesService { public url:String; constructor(private _http: HttpClient) { this.url='https://reqres.in'; } getConfig(): Observable { return this._http.get(this.url+'/api/users/2'); } }
и это мой component
import { Component, OnInit } from '@angular/core'; import { PeticionesService } from '../services/peticiones.service' @Component({ selector: 'externo', templateUrl: './externo.component.html', styleUrls: ['./externo.component.css'], providers:[PeticionesService] }) export class ExternoComponent implements OnInit { public user:any; constructor(private _peticionesservice: PeticionesService) {} ngOnInit() { this._peticionesservice.getConfig().subscribe( result => { this.user= result.data; console.log(result); }, error => { console.log(error); } ); } }
Porqué ты распределяешь result.data в тебя this.user
? Его не было бы должно быть this.user = result;
?