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