|
|
@@ -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();
|