dataProvider.ts 695 B

12345678910111213141516171819202122232425262728293031323334
  1. import ApiRequestService from "./apiRequestService";
  2. class dataProvider {
  3. private apiRequestService: ApiRequestService;
  4. public constructor(apiRequestService: ApiRequestService) {
  5. this.apiRequestService = apiRequestService;
  6. }
  7. public async fetchNews(): Promise<{ news }> {
  8. const response = await this.apiRequestService.get(
  9. "/news"
  10. );
  11. console.log(response)
  12. return {
  13. news: response,
  14. };
  15. }
  16. public async fetchNew(
  17. id: number
  18. ): Promise<{ new }> {
  19. const response = await this.apiRequestService.get(
  20. "/news/" + id
  21. );
  22. console.log(response)
  23. return {
  24. new: response,
  25. };
  26. }
  27. }
  28. export default dataProvider;