Update lib/scrapper.js
Browse files- lib/scrapper.js +13 -0
lib/scrapper.js
CHANGED
@@ -9,6 +9,16 @@ const ParametersUrl = function (parameters) {
|
|
9 |
return WhatDoesThis
|
10 |
};
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
const Copilot2Trip = async (query) => {
|
13 |
try {
|
14 |
const url = ParametersUrl("ai/copilot2trip");
|
@@ -17,6 +27,8 @@ const Copilot2Trip = async (query) => {
|
|
17 |
q: query
|
18 |
},
|
19 |
});
|
|
|
|
|
20 |
if (typeof response.data === "object") {
|
21 |
response.data.author = "xtdevs";
|
22 |
return response.data;
|
@@ -24,6 +36,7 @@ const Copilot2Trip = async (query) => {
|
|
24 |
console.log("the return value was not a json object");
|
25 |
return null;
|
26 |
}
|
|
|
27 |
} catch (e) {
|
28 |
console.error("Error:", e.message);
|
29 |
return null;
|
|
|
9 |
return WhatDoesThis
|
10 |
};
|
11 |
|
12 |
+
const AuthorOriginal = function (response) {
|
13 |
+
if (typeof response.data === "object") {
|
14 |
+
response.data.author = "xtdevs";
|
15 |
+
return response.data;
|
16 |
+
} else {
|
17 |
+
console.log("the return value was not a json object");
|
18 |
+
return null;
|
19 |
+
}
|
20 |
+
};
|
21 |
+
|
22 |
const Copilot2Trip = async (query) => {
|
23 |
try {
|
24 |
const url = ParametersUrl("ai/copilot2trip");
|
|
|
27 |
q: query
|
28 |
},
|
29 |
});
|
30 |
+
return AuthorOriginal(response)
|
31 |
+
/*
|
32 |
if (typeof response.data === "object") {
|
33 |
response.data.author = "xtdevs";
|
34 |
return response.data;
|
|
|
36 |
console.log("the return value was not a json object");
|
37 |
return null;
|
38 |
}
|
39 |
+
*/
|
40 |
} catch (e) {
|
41 |
console.error("Error:", e.message);
|
42 |
return null;
|