From 8780fd71223e4f6b7cf2556dc67acee6266c24ff Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Thu, 2 Nov 2023 21:54:09 +0200 Subject: [PATCH] axios error --- FrontEnd/src/components/SearchPage/Search.js | 15 ++++++++++++++- .../search_field/companies/CompanyCard.js | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/FrontEnd/src/components/SearchPage/Search.js b/FrontEnd/src/components/SearchPage/Search.js index 438c8fd3d..2194964bb 100644 --- a/FrontEnd/src/components/SearchPage/Search.js +++ b/FrontEnd/src/components/SearchPage/Search.js @@ -29,7 +29,20 @@ export function Search({ isAuthorized }) { const searchUrl = 'search'; const { mutate } = useSWRConfig(); - const fetcher = (url) => axios.get(url).then((res) => res.data); + const fetcher = (url) => + axios + .get(url) + .then((res) => res.data) + .catch(function (error) { + if (error.response) { + console.log(error.response.data); + } else if (error.request) { + console.log(error.request); + } else { + console.log('Error', error.message); + } + console.log(error.config); + }); async function getRequest(url) { const data = await fetcher(url); diff --git a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js index 0aaad6809..cc7df3c63 100644 --- a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js +++ b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js @@ -48,6 +48,15 @@ const CompanyCard = ({ companyData, isAuthorized }) => { }) .then((response) => { return response.data; + }) + .catch(function (error) { + if (error.response) { + console.log(error.response.data); + } else if (error.request) { + console.log(error.request); + } else { + console.log('Error', error.message); + } }); const NewList = []; for (let item of data.results) {