@resistdesign/voltra 3.0.0-alpha.37 → 3.0.0-alpha.39

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.
Files changed (2) hide show
  1. package/app/index.js +19 -6
  2. package/package.json +1 -1
package/app/index.js CHANGED
@@ -144,10 +144,10 @@ var getFullUrl = (protocol, domain, basePath = "", path = "", port) => {
144
144
  path,
145
145
  PATH_DELIMITER,
146
146
  false,
147
- false,
147
+ true,
148
148
  false
149
149
  );
150
- const normalizedPath = fullPath ? fullPath.startsWith(PATH_DELIMITER) ? fullPath : `${PATH_DELIMITER}${fullPath}` : "";
150
+ const normalizedPath = fullPath ? fullPath.startsWith(PATH_DELIMITER) ? fullPath : `${PATH_DELIMITER}${fullPath}` : PATH_DELIMITER;
151
151
  return `${normalizedProtocol}://${normalizedDomain}${portString}${normalizedPath}`;
152
152
  };
153
153
  var sendServiceRequest = async (config, path = "", args = []) => {
@@ -166,11 +166,24 @@ var sendServiceRequest = async (config, path = "", args = []) => {
166
166
  body: JSON.stringify(args)
167
167
  });
168
168
  const { ok: responseIsOk } = response;
169
- const data = await response.json();
170
- if (responseIsOk) {
171
- return data;
169
+ const textData = await response.text();
170
+ let data = textData;
171
+ try {
172
+ data = JSON.parse(textData);
173
+ } catch (error) {
174
+ }
175
+ if (typeof data === "object") {
176
+ if (responseIsOk) {
177
+ return data;
178
+ } else {
179
+ throw data;
180
+ }
172
181
  } else {
173
- throw data;
182
+ if (responseIsOk) {
183
+ return { data };
184
+ } else {
185
+ throw { message: data };
186
+ }
174
187
  }
175
188
  };
176
189
  var useApplicationStateLoader = (config) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resistdesign/voltra",
3
- "version": "3.0.0-alpha.37",
3
+ "version": "3.0.0-alpha.39",
4
4
  "description": "With our powers combined!",
5
5
  "homepage": "https://voltra.app",
6
6
  "repository": "git@github.com:resistdesign/voltra.git",