Skip to content

Commit

Permalink
performance (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xk4b1r authored Sep 15, 2024
1 parent b54ca16 commit 16f2ac7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/Resources/Hackliner/Hackliner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "src/components/Resources/Hacklist/HacklistElements.jsx";
import { CodeBlock } from "src/components/Resources/Hacklist/Hacklist.jsx";
import { useParams } from "react-router-dom";
import { getApiUrl } from "src/features/apiUrl.js";

const Hackliners = () => {
const { title } = useParams();
Expand All @@ -22,7 +23,7 @@ const Hackliners = () => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await axios.get(`http://localhost:5000/api/resources/${title}`);
const response = await axios.get(getApiUrl(`/api/resources/${title}`));
setData(response?.data);
console.log("Fetched data:", response?.data);
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Resources/ResourcesElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "src/components/Resources/Hacklist/HacklistElements.jsx";
import { CodeBlock } from "src/components/Resources/Hacklist/Hacklist.jsx";
import { useParams } from "react-router-dom";
import { getApiUrl } from "src/features/apiUrl.js";

const Hackliners = () => {
const { title } = useParams();
Expand All @@ -23,7 +24,7 @@ const Hackliners = () => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await axios.get(`http://localhost:5000/api/resources/${title}`);
const response = await axios.get(getApiUrl(`/api/resources/${title}`));
setData(response?.data);
} catch (error) {
setError(error);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Tools/SubdomainFinder/SubdomainFinder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CircleSpinner } from "react-spinners-kit";
import apiStatus from "src/features/apiStatus";
import UnderMaintenance from "src/components/Other/UnderMaintenance/UnderMaintenance";
import { RiEarthFill } from "react-icons/ri";
import { getApiUrl } from "src/features/apiUrl.js";

const SubdomainFinder = () => {
const { isApiLoading, isApiWorking } = apiStatus();
Expand All @@ -41,7 +42,7 @@ const SubdomainFinder = () => {
return;
}
try {
const response = await axios.get(`http://localhost:5000/api/subdomains?domain=${domainName}`);
const response = await axios.get(getApiUrl(`/api/subdomains?domain=${domainName}`));
setSubdomains(response?.data?.subdomains);
setIsLoading(false);
} catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/WebSecurity/WebSecurityTopics/Topic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container } from "./TopicElements";
import Sidebar from "src/components/WebSecurity/Sidebar";
import SubTopic from "./SubTopic";
import axios from "axios";
import { getApiUrl } from "src/features/apiUrl.js";

const Topic = () => {
const { id } = useParams();
Expand All @@ -16,10 +17,10 @@ const Topic = () => {
const fetchData = async () => {
setLoading(true);
try {
const topicsResponse = await axios.get("http://localhost:5000/api/topics/sidebar");
const topicsResponse = await axios.get(getApiUrl("/api/topics/sidebar"));
setTopics(topicsResponse.data);

const topicResponse = await axios.get(`http://localhost:5000/api/topics/${id}`);
const topicResponse = await axios.get(getApiUrl(`/api/topics/${id}`));
setTopic(topicResponse.data);

setLoading(false); // Stops loading after both requests complete
Expand Down
3 changes: 2 additions & 1 deletion src/components/WebSecurity/WebSecurityTopics/Topics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TopicsContainer,
Container,
} from "src/components/WebSecurity/WebSecurityTopics/TopicElements.jsx";
import { getApiUrl } from "src/features/apiUrl.js";

const Topics = () => {
const [topics, setTopics] = useState([]);
Expand All @@ -24,7 +25,7 @@ const Topics = () => {
// Fetch data from the API
const fetchData = async () => {
try {
const response = await axios.get("http://localhost:5000/api/topics");
const response = await axios.get(getApiUrl("/api/topics"));
setTopics(response.data); // Update state with the fetched data
setLoading(false); // Stop loading when data is received
} catch (err) {
Expand Down

0 comments on commit 16f2ac7

Please sign in to comment.