From be306972118245748490467f1e2d6ec647a62702 Mon Sep 17 00:00:00 2001 From: gugahnstn Date: Sun, 24 Sep 2023 22:26:30 -0300 Subject: [PATCH] feat: Adding the 'requestDomainAndIp' variable and passing it as a parameter to the 'serviceIpApi' function. --- src/contexts/ip-search.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/contexts/ip-search.tsx b/src/contexts/ip-search.tsx index 00ec689..143f290 100644 --- a/src/contexts/ip-search.tsx +++ b/src/contexts/ip-search.tsx @@ -7,6 +7,7 @@ import { } from "react"; import serviceIpApi from "../services/service-ip-api"; import { Data, ipSearchType } from "../types"; +import searchIp from "../services/search-ip"; export const IpSearchContext = createContext({} as ipSearchType); @@ -15,8 +16,9 @@ export const IpSearchProvider = ({ children }: PropsWithChildren) => { const [search, setSearch] = useState(""); const settingIpApi = async () => { - const getServiceIpApi = await serviceIpApi(search); - console.log("olá"); + const query = await searchIp(); + const requestDomainAndIp = search || query; + const getServiceIpApi = await serviceIpApi(requestDomainAndIp); setData({ continent: getServiceIpApi.continent, flag: getServiceIpApi.countryCode, @@ -46,4 +48,4 @@ export const IpSearchProvider = ({ children }: PropsWithChildren) => { {children} ); -}; +}; \ No newline at end of file