@malevich-studio/strapi-sdk-typescript 1.2.8 → 1.2.10
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/dist/cli.cjs +8 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +8 -9
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -21320,18 +21320,16 @@ class Strapi {
|
|
|
21320
21320
|
this.token = token;
|
|
21321
21321
|
}
|
|
21322
21322
|
async fetch(endpoint, data = {}, params = {}) {
|
|
21323
|
-
|
|
21323
|
+
const queryString = params.method === 'GET' ? qs.stringify(data) : '';
|
|
21324
|
+
return await this.fetchData(queryString ? `${endpoint}?${queryString}` : endpoint, { data }, params);
|
|
21324
21325
|
}
|
|
21325
21326
|
async fetchData(endpoint, data = {}, params = {}) {
|
|
21326
|
-
|
|
21327
|
-
return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
|
|
21327
|
+
return await this.baseFetch(endpoint, _.merge({
|
|
21328
21328
|
headers: {
|
|
21329
21329
|
'Content-Type': 'application/json',
|
|
21330
21330
|
},
|
|
21331
21331
|
...(params.method && !['GET', 'DELETE'].includes(params.method) ? {
|
|
21332
|
-
body: JSON.stringify(
|
|
21333
|
-
data,
|
|
21334
|
-
})
|
|
21332
|
+
body: JSON.stringify(data)
|
|
21335
21333
|
} : {}),
|
|
21336
21334
|
}, params));
|
|
21337
21335
|
}
|
|
@@ -21443,15 +21441,16 @@ class Strapi {
|
|
|
21443
21441
|
}));
|
|
21444
21442
|
}
|
|
21445
21443
|
async baseFetch(endpoint, params = {}) {
|
|
21446
|
-
const
|
|
21444
|
+
const mergedParams = _.merge({
|
|
21447
21445
|
...(this.token ? {
|
|
21448
21446
|
headers: {
|
|
21449
21447
|
Authorization: `Bearer ${this.token}`,
|
|
21450
21448
|
}
|
|
21451
21449
|
} : {}),
|
|
21452
|
-
}, params)
|
|
21450
|
+
}, params);
|
|
21451
|
+
const response = await fetch(`${this.url}/api/${endpoint}`, mergedParams);
|
|
21453
21452
|
const data = await response.json();
|
|
21454
|
-
log(
|
|
21453
|
+
log(mergedParams);
|
|
21455
21454
|
log(response);
|
|
21456
21455
|
log(data);
|
|
21457
21456
|
return data;
|