Im 를 사용하려서 외부 api 를 nestjs 진 날개로 연기 드리프트 같이하지만.
@Injectable()
export class PIntegration {
constructor(private httpService: HttpService) { }
API = process.env.API || 'http://localhost:3000';
header = { headers: { 'Content-Type': 'application/json' } };
async getPrestacionById(id: string): Promise<Observable<IPrestacion>>{
return this.httpService.get(`${this.API}/prestacion/${id}`, this.header).pipe(map((res) => res.data));
}
}
내 서비스 등 다음과 같습니다:
@Injectable()
export class ProductService{
constructor(private pIntegration: PIntegration){}
async producto(id: string) {
const infoPrestacion = await this.pIntegration.getPrestacionById(id);
console.log({ infoPrestacion })
if (infoPrestacion)
{
if (infoPrestacion.detalles) {
console.log(infoPrestacion.detalles)
console.log("tiene detalles")
}
}
return infoPrestacion;
}
}
그러나면 콘솔입니다.로그 값이"infoPrestacion"이것은 결과는 다음과 같다:
{
infoPrestacion: Observable {
source: Observable { _subscribe: [Function (anonymous)] },
operator: [Function (anonymous)]
}
}
고 그것은 두번째 이후 그것은 아직 해결되지 않. 그것은 가능한 결과를 기다릴 때까지 그것의 해결(i 없 config 에 대한 HttpModule)? 반환이 실제로 개체"infoPrestacion"그러나 나는 일할 필요가 가진 값을 반환하지 않는 객체입니다.