@nuskin/ns-product-lib 2.0.0-cx24-2382.3 → 2.0.0-cx24-2382.4
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/contentstack/contentstack.js +14 -18
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [2.0.0-cx24-2382.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.0.0-cx24-2382.3...v2.0.0-cx24-2382.4) (2022-09-08)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* change the parameters passed to getProductData (CX24-2382) ([7e29c09](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7e29c09396b44ee9f959e2a461940b5fcc382743))
|
7
|
+
|
1
8
|
# [2.0.0-cx24-2382.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.0.0-cx24-2382.2...v2.0.0-cx24-2382.3) (2022-09-08)
|
2
9
|
|
3
10
|
|
package/package.json
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
const axios = require('axios');
|
3
3
|
const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
4
4
|
|
5
|
+
const url = 'https://graphql.contentstack.com';
|
6
|
+
const apiKey = 'blt7d4c4f4a1bf5a819';
|
7
|
+
const env = 'public-dev';
|
8
|
+
const baseURL = `${url}/stacks/${apiKey}?environment=${env}`;
|
9
|
+
const deliveryToken = 'cs74599c107573ea7f6c7a1413';
|
10
|
+
const headers = {
|
11
|
+
'access_token': `${deliveryToken}`,
|
12
|
+
'Content-Type': 'application/json'
|
13
|
+
};
|
14
|
+
const http = axios.create({ baseURL, headers });
|
15
|
+
|
5
16
|
/**
|
6
17
|
* getAEMConfig fetches the market config from contentstack.
|
7
18
|
*
|
@@ -18,7 +29,7 @@ async function getAEMConfig() {
|
|
18
29
|
const env = getEnvironmentFromUrl('test.nuskin.com');
|
19
30
|
const marketConfig = `market_config_${env}`;
|
20
31
|
const variables = { uid: 'blt52b0b83a89763791' };
|
21
|
-
const query = `query
|
32
|
+
const query = `query AemConfigByUid($uid: String!) {
|
22
33
|
aem_config(uid: $uid) {
|
23
34
|
title
|
24
35
|
${marketConfig} {
|
@@ -30,7 +41,6 @@ async function getAEMConfig() {
|
|
30
41
|
}`;
|
31
42
|
|
32
43
|
const { data } = await contentstackService({
|
33
|
-
method: 'post',
|
34
44
|
data: { variables, query }
|
35
45
|
});
|
36
46
|
|
@@ -74,7 +84,6 @@ async function getEquinoxMarkets() {
|
|
74
84
|
}`;
|
75
85
|
|
76
86
|
const { data } = await contentstackService({
|
77
|
-
method: 'post',
|
78
87
|
data: { variables, query }
|
79
88
|
});
|
80
89
|
|
@@ -85,8 +94,6 @@ async function getEquinoxMarkets() {
|
|
85
94
|
}
|
86
95
|
}
|
87
96
|
|
88
|
-
|
89
|
-
|
90
97
|
/**
|
91
98
|
* Contentstack HTTP - axios wrapper for contentstack request
|
92
99
|
*
|
@@ -94,21 +101,10 @@ async function getEquinoxMarkets() {
|
|
94
101
|
* @return {Promise<import('axios').AxiosResponse>} Promise that resolves to market_list_eq object
|
95
102
|
*/
|
96
103
|
async function contentstackService(config) {
|
97
|
-
const
|
98
|
-
const deliveryToken = 'cs74599c107573ea7f6c7a1413';
|
99
|
-
const apiKey = 'blt7d4c4f4a1bf5a819';
|
100
|
-
const env = 'public-dev';
|
101
|
-
const defaultUrl = `${baseURL}/stacks/${apiKey}?environment=${env}`;
|
102
|
-
|
103
|
-
config.method = config.method || 'get'
|
104
|
-
config.url = config.url || defaultUrl
|
105
|
-
config.headers = {
|
106
|
-
'access_token': `${deliveryToken}`,
|
107
|
-
'Content-Type': 'application/json'
|
108
|
-
}
|
104
|
+
const data = JSON.parse(JSON.stringify(config.data));
|
109
105
|
|
110
106
|
try {
|
111
|
-
const response = await
|
107
|
+
const response = await http.post('', data);
|
112
108
|
return response.data
|
113
109
|
} catch (error) {
|
114
110
|
console.error(error.response.data.errors);
|