выводил тип возвращаемой сущности? Сейчас реализовано так type Request = (method: string, url: string, data?: any) => Promise<any>;
                  
                  
                  
                  
                  
                  const request: Request = async (method, url, data) => {
                  
                  
                    const h = new Headers();
                  
                  
                    h.append("Content-Type", "application/json");
                  
                  
                  
                  
                  
                    const options: RequestInit = {
                  
                  
                      method: method.toUpperCase(),
                  
                  
                      headers: h
                  
                  
                    };
                  
                  
                  
                  
                  
                    if (data) options.body = JSON.stringify(data);
                  
                  
                  
                  
                  
                    const x = await fetch(`${API_ROOT}${url}`, options);
                  
                  
                  
                  
                  
                    return x.json();
                  
                  
                  };
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  export const get = (url: string) => request("get", url);
                  
                  
                  export const post = (url: string, body: any) => request("post", url, body);
                  
                  
                  export const put = (url: string, body: any) => request("put", url, body);
                  
                  
                  export const del = (url: string) => request("del", url);
                  
                  
                
Делай отдельный класс Api/Service
Обсуждают сегодня