Показать сообщение отдельно
  #1 (permalink)  
Старый 09.11.2021, 01:17
Интересующийся
Отправить личное сообщение для FlyTen Посмотреть профиль Найти все сообщения от FlyTen
 
Регистрация: 02.03.2021
Сообщений: 17

Проблема с дженериками
Добрый вечер ,
проблема с дженереками .

export interface Location {
  id: number;
  address: {
    houseNumber: string;
  };
}
export const getEuropeLocations = async (
  apiKey: string
): Promise<Locations> => {
  let response = await axios({
    method: "get",
    url: `${apiBaseUrl}europe/`,
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  });
  return response.data as Locations;
};



Пытаюсь сделать из getEuropeLocations используя generics :

export const getEuropeLocations = async (
  apiKey: string
) => {
  let response = await axios.get<Location>({
    method: "get",
    url: `${apiBaseUrl}europe/`,
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  });
  return response.data;
};


в чем моя ошибка?
Ответить с цитированием