Nest.js
In Nest.js, you can use the HttpModule or a library like axios to make API requests. Here's an example using the HttpModule:
import { HttpModule, HttpService } from '@nestjs/common';
@Injectable()
export class ApiService {
constructor(private httpService: HttpService) {}
async fetchData() {
const response = await this.httpService.get('https://api.tinyapi.co/your-api-endpoint', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}).toPromise();
return response.data;
}
}