powr-sdk-web 2.4.0 → 2.4.1
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/chat/index.js +12 -3
- package/package.json +1 -1
package/dist/chat/index.js
CHANGED
|
@@ -100,7 +100,9 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
100
100
|
var options,
|
|
101
101
|
token,
|
|
102
102
|
url,
|
|
103
|
+
separator,
|
|
103
104
|
config,
|
|
105
|
+
bodyWithProjectId,
|
|
104
106
|
response,
|
|
105
107
|
data,
|
|
106
108
|
_args = arguments;
|
|
@@ -109,16 +111,23 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
109
111
|
case 0:
|
|
110
112
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
111
113
|
token = getAuthToken();
|
|
112
|
-
url = "".concat(apiUrl).concat(endpoint);
|
|
114
|
+
url = "".concat(apiUrl).concat(endpoint); // Add projectId as query parameter for GET requests
|
|
115
|
+
if (!options.method || options.method === 'GET') {
|
|
116
|
+
separator = endpoint.includes('?') ? '&' : '?';
|
|
117
|
+
url = "".concat(url).concat(separator, "projectId=").concat(projectId);
|
|
118
|
+
}
|
|
113
119
|
config = _objectSpread({
|
|
114
120
|
headers: _objectSpread(_objectSpread({
|
|
115
121
|
'Content-Type': 'application/json'
|
|
116
122
|
}, token && {
|
|
117
123
|
'Authorization': "Bearer ".concat(token)
|
|
118
124
|
}), options.headers)
|
|
119
|
-
}, options);
|
|
125
|
+
}, options); // Add projectId to body for POST/PUT requests
|
|
120
126
|
if (options.body) {
|
|
121
|
-
|
|
127
|
+
bodyWithProjectId = _objectSpread(_objectSpread({}, options.body), {}, {
|
|
128
|
+
projectId: projectId
|
|
129
|
+
});
|
|
130
|
+
config.body = JSON.stringify(bodyWithProjectId);
|
|
122
131
|
}
|
|
123
132
|
_context.n = 1;
|
|
124
133
|
return fetch(url, config);
|