fetchfox-sdk 1.0.22 → 1.0.24

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +7 -1
  3. package/src/jobs.js +10 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetchfox-sdk",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "AI scraper",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/api.js CHANGED
@@ -30,7 +30,13 @@ export const call = async (method, path, params) => {
30
30
 
31
31
  let url = endpoint(path, params);
32
32
  if (method == 'GET') {
33
- url += '?' + new URLSearchParams(params).toString();
33
+ const clean = {};
34
+ for (const key of Object.keys(params || {})) {
35
+ if (params[key] !== undefined && params[key] !== null) {
36
+ clean[key] = params[key];
37
+ }
38
+ }
39
+ url += '?' + new URLSearchParams(clean).toString();
34
40
  } else {
35
41
  args.body = JSON.stringify(params);
36
42
  }
package/src/jobs.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { call } from './api.js';
2
2
 
3
3
  export const jobs = {
4
- get: async (id) => {
4
+ get: (id) => {
5
5
  return call('GET', `/api/jobs/${id}`);
6
6
  },
7
- list: async (args) => {
8
- const params = {};
9
- params.limit = args?.limit ?? 100;
10
- params.offset = args?.offset ?? 0;
7
+ stop: (id) => {
8
+ return call('POST', `/api/jobs/${id}/stop`);
9
+ },
10
+ list: (args) => {
11
+ const params = { ...args };
11
12
 
12
- if (args?.types) {
13
- if (Array.isArray(args.types)) {
14
- params.types = args.types.join(',');
13
+ if (parms?.types) {
14
+ if (Array.isArray(params.types)) {
15
+ params.types = params.types.join(',');
15
16
  } else {
16
- params.types = args.types;
17
+ params.types = params.types;
17
18
  }
18
19
  }
19
- const types = args?.types ?? 0;
20
20
  return call('GET', '/api/jobs', params);
21
21
  },
22
22
  };