$ npm i --save @nestjs/axios axios
curl
로 요청 보내는 방법@Injectable()
export class CatsService {
constructor(private readonly httpService: HttpService) {}
findAll(): Observable<AxiosResponse<Cat[]>> {
return this.httpService.get('<http://localhost:3000/cats>');
}
}
<aside> 🍎 firstValueFrom() lastValueFrom()
</aside>
httpService.get()
, httpService.post()
등의 요청의 반환 값은 Observable<AxiosResponse>
firstValueFrom
과 lastValueFrom