Skip to content

Commit

Permalink
feat: Adding the 'requestDomainAndIp' variable and passing it as a pa…
Browse files Browse the repository at this point in the history
…rameter to the 'serviceIpApi' function.
  • Loading branch information
Gugahnstn committed Sep 25, 2023
1 parent d3f00a7 commit be30697
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/contexts/ip-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -46,4 +48,4 @@ export const IpSearchProvider = ({ children }: PropsWithChildren) => {
{children}
</IpSearchContext.Provider>
);
};
};

0 comments on commit be30697

Please sign in to comment.