Add fetch as parameter for repo

This commit is contained in:
Alessio Davoli 2023-12-22 12:53:19 +01:00
parent 536b84af2d
commit cc11368926

View file

@ -1,6 +1,6 @@
const API_URL = "https://ale-dev.teck-developer.com/api";
const getAllRoutes = async () => {
const getAllRoutes = async (fetch) => {
let data = [];
const response = await fetch(`${API_URL}/all-routes`);
@ -10,7 +10,7 @@ const getAllRoutes = async () => {
return data;
}
const getRouteCategories = async () => {
const getRouteCategories = async (fetch) => {
let data = [];
const response = await fetch(`${API_URL}/route-categories`);
@ -20,7 +20,7 @@ const getRouteCategories = async () => {
return data;
}
const getRouteByCategory = async (categoryId: number) => {
const getRouteByCategory = async (fetch,categoryId: number) => {
let data = [];
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const json = await response.json();
@ -29,7 +29,7 @@ const getRouteByCategory = async (categoryId: number) => {
return data;
}
const getRoute = async (routeId: number) => {
const getRoute = async (fetch,routeId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}`);
const json = await response.json();
@ -39,7 +39,7 @@ const getRoute = async (routeId: number) => {
}
const getSport = async (routeId: number, sportId: number) => {
const getSport = async (fetch,routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
const json = await response.json();
@ -48,7 +48,7 @@ const getSport = async (routeId: number, sportId: number) => {
return data;
}
const getPlacemarks = async (routeId: number, sportId: number) => {
const getPlacemarks = async (fetch,routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
const json = await response.json();