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