simple page with news from all around the globe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

24 lines
899B

  1. import { HttpClient } from '@angular/common/http';
  2. import { Injectable } from '@angular/core';
  3. import { Observable } from 'rxjs';
  4. import { environment } from '../../environments/environment';
  5. import { TopHeadlineSearchDto } from '../models/dto/top-headline-search.dto';
  6. import { NewsSearchDto } from '../models/dto/news-search.dto';
  7. import { NewsResponse } from '../models/response/news-response';
  8. @Injectable({
  9. providedIn: 'root'
  10. })
  11. export class NewsService {
  12. constructor(protected http: HttpClient) { }
  13. searchTopNews(searchDto: TopHeadlineSearchDto): Observable<NewsResponse> | null {
  14. return this.http.get<NewsResponse>(`${environment.apiUrl}/top-headlines`, { params: searchDto as any });
  15. }
  16. searchAllNews(searchDto: NewsSearchDto): Observable<NewsResponse> | null {
  17. return this.http.get<NewsResponse>(`${environment.apiUrl}/everything`, { params: searchDto as any });
  18. }
  19. }