@apiverve/advice 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/examples/basic.js +15 -13
- package/index.d.ts +8 -1
- package/index.js +13 -4
- package/package.json +5 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 APIVerve, and EvlarSoft LLC
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ All usage of the APIVerve website, API, and services is subject to the [APIVerve
|
|
|
145
145
|
## License
|
|
146
146
|
Licensed under the The MIT License (MIT)
|
|
147
147
|
|
|
148
|
-
Copyright (©) 2025 APIVerve, and
|
|
148
|
+
Copyright (©) 2025 APIVerve, and EvlarSoft LLC
|
|
149
149
|
|
|
150
150
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
151
151
|
|
package/examples/basic.js
CHANGED
|
@@ -16,19 +16,21 @@ const api = new adviceAPI({
|
|
|
16
16
|
// Example query
|
|
17
17
|
// This API does not require a Query
|
|
18
18
|
|
|
19
|
-
// Make the API request
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.error(
|
|
19
|
+
// Make the API request using callback
|
|
20
|
+
console.log('Making request to Advice Generator API...\n');
|
|
21
|
+
|
|
22
|
+
api.execute(function (error, data) {
|
|
23
|
+
if (error) {
|
|
24
|
+
console.error('Error occurred:');
|
|
25
|
+
if (error.error) {
|
|
26
|
+
console.error('Message:', error.error);
|
|
27
|
+
console.error('Status:', error.status);
|
|
28
|
+
} else {
|
|
29
|
+
console.error(JSON.stringify(error, null, 2));
|
|
30
30
|
}
|
|
31
|
+
return;
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
console.log('Response:');
|
|
35
|
+
console.log(JSON.stringify(data, null, 2));
|
|
36
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -7,10 +7,17 @@ declare module '@apiverve/advice' {
|
|
|
7
7
|
export interface adviceResponse {
|
|
8
8
|
status: string;
|
|
9
9
|
error: string | null;
|
|
10
|
-
data:
|
|
10
|
+
data: AdviceGeneratorData;
|
|
11
11
|
code?: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
interface AdviceGeneratorData {
|
|
16
|
+
id: string;
|
|
17
|
+
advice: string;
|
|
18
|
+
lang: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
export default class adviceWrapper {
|
|
15
22
|
constructor(options: adviceOptions);
|
|
16
23
|
|
package/index.js
CHANGED
|
@@ -86,13 +86,22 @@ class adviceWrapper {
|
|
|
86
86
|
if (callback) callback(null, data);
|
|
87
87
|
return data;
|
|
88
88
|
} catch (error) {
|
|
89
|
+
let apiError;
|
|
90
|
+
|
|
89
91
|
if (error.response && error.response.data) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
apiError = error.response.data;
|
|
93
|
+
} else if (error.message) {
|
|
94
|
+
apiError = { error: error.message, status: 'error' };
|
|
92
95
|
} else {
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
apiError = { error: 'An unknown error occurred', status: 'error' };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (callback) {
|
|
100
|
+
callback(apiError, null);
|
|
101
|
+
return; // Don't throw if callback is provided
|
|
95
102
|
}
|
|
103
|
+
|
|
104
|
+
throw apiError;
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/advice",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Advice Generator is a simple tool for generating random pieces of advice. It returns a random piece of advice.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/apiverve/advice-
|
|
13
|
+
"url": "git+https://github.com/apiverve/advice-api.git",
|
|
14
|
+
"directory": "npm"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"advice generator", "advice generation", "advice generate", "advice api", "advice tool"
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/apiverve/advice-
|
|
22
|
+
"url": "https://github.com/apiverve/advice-api/issues"
|
|
22
23
|
},
|
|
23
24
|
"homepage": "https://apiverve.com/marketplace/advice?utm_source=npm",
|
|
24
25
|
"devDependencies": {
|
|
@@ -29,6 +30,6 @@
|
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"node-fetch": "^3.3.2",
|
|
31
32
|
"promise": "^8.3.0",
|
|
32
|
-
"axios": "1.
|
|
33
|
+
"axios": "1.13.2"
|
|
33
34
|
}
|
|
34
35
|
}
|