@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.mjs
CHANGED
|
@@ -21300,18 +21300,16 @@ class Strapi {
|
|
|
21300
21300
|
this.token = token;
|
|
21301
21301
|
}
|
|
21302
21302
|
async fetch(endpoint, data = {}, params = {}) {
|
|
21303
|
-
|
|
21303
|
+
const queryString = params.method === 'GET' ? qs.stringify(data) : '';
|
|
21304
|
+
return await this.fetchData(queryString ? `${endpoint}?${queryString}` : endpoint, { data }, params);
|
|
21304
21305
|
}
|
|
21305
21306
|
async fetchData(endpoint, data = {}, params = {}) {
|
|
21306
|
-
|
|
21307
|
-
return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
|
|
21307
|
+
return await this.baseFetch(endpoint, _.merge({
|
|
21308
21308
|
headers: {
|
|
21309
21309
|
'Content-Type': 'application/json',
|
|
21310
21310
|
},
|
|
21311
21311
|
...(params.method && !['GET', 'DELETE'].includes(params.method) ? {
|
|
21312
|
-
body: JSON.stringify(
|
|
21313
|
-
data,
|
|
21314
|
-
})
|
|
21312
|
+
body: JSON.stringify(data)
|
|
21315
21313
|
} : {}),
|
|
21316
21314
|
}, params));
|
|
21317
21315
|
}
|
|
@@ -21423,15 +21421,16 @@ class Strapi {
|
|
|
21423
21421
|
}));
|
|
21424
21422
|
}
|
|
21425
21423
|
async baseFetch(endpoint, params = {}) {
|
|
21426
|
-
const
|
|
21424
|
+
const mergedParams = _.merge({
|
|
21427
21425
|
...(this.token ? {
|
|
21428
21426
|
headers: {
|
|
21429
21427
|
Authorization: `Bearer ${this.token}`,
|
|
21430
21428
|
}
|
|
21431
21429
|
} : {}),
|
|
21432
|
-
}, params)
|
|
21430
|
+
}, params);
|
|
21431
|
+
const response = await fetch(`${this.url}/api/${endpoint}`, mergedParams);
|
|
21433
21432
|
const data = await response.json();
|
|
21434
|
-
log(
|
|
21433
|
+
log(mergedParams);
|
|
21435
21434
|
log(response);
|
|
21436
21435
|
log(data);
|
|
21437
21436
|
return data;
|