yazid138 пре 3 година
родитељ
комит
0e93736c63
1 измењених фајлова са 2 додато и 6 уклоњено
  1. 2 6
      actions/PT.js

+ 2 - 6
actions/PT.js

@@ -2,9 +2,6 @@ import https from "https";
 
 export const getPT = async (params) => {
 	try {
-		const controller = new AbortController();
-		const timeoutId = setTimeout(() => controller.abort(), 10000);
-
 		const httpsAgent = new https.Agent({
 			rejectUnauthorized: false,
 		});
@@ -15,6 +12,8 @@ export const getPT = async (params) => {
 			url += `?q=${params.search}`;
 		}
 
+		const controller = new AbortController();
+		const timeoutId = setTimeout(() => controller.abort(), 10000);
 		const res = await fetch(url, {
 			method: "GET",
 			headers: new Headers({
@@ -25,9 +24,6 @@ export const getPT = async (params) => {
 			agent: httpsAgent,
 			signal: controller.signal,
 		});
-		if (!res.ok) {
-			throw new Error(`Error! status: ${response.status}`);
-		}
 
 		clearTimeout(timeoutId);
 		const result = await res.json();