@selkirk-systems/fetch 0.1.2 → 0.1.3

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 (3) hide show
  1. package/dist/index.js +10 -10
  2. package/package.json +1 -1
  3. package/src/index.js +11 -11
package/dist/index.js CHANGED
@@ -10,22 +10,22 @@ var _networkTimer = null;
10
10
 
11
11
  function _checkFetchStatus(response) {
12
12
  if (response.status >= 200 && response.status < 300) {
13
- if (response.text.length > 0) {
14
- return response.json();
15
- }
13
+ return response.json();
16
14
  } else {
17
15
  var error = new Error(response.statusText);
18
- if (response.text.length) {
19
- return response.json().then(function (result) {
20
- error.response = result;
21
- throw error;
22
- });
23
- } else {
16
+ return response.json().then(function (result) {
17
+ error.response = result;
24
18
  throw error;
25
- }
19
+ });
26
20
  }
27
21
  }
28
22
 
23
+ function _parseJSON(response) {
24
+ return response.text().then(function (text) {
25
+ return text ? JSON.parse(text) : {};
26
+ });
27
+ }
28
+
29
29
  function _invokeFetch(url, props) {
30
30
  if (!url) {
31
31
  throw new Error("fetch:Missing Parameter - URL");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selkirk-systems/fetch",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A wrapper on fetch-polyfill that will work for server and client environments",
5
5
  "selkirk": {
6
6
  "bambooDeploy": "npm",
package/src/index.js CHANGED
@@ -8,22 +8,22 @@ const _networkTimer = null;
8
8
 
9
9
  function _checkFetchStatus(response) {
10
10
  if (response.status >= 200 && response.status < 300) {
11
- if (response.text.length > 0) {
12
- return response.json()
13
- }
11
+ return response.json()
14
12
  } else {
15
13
  var error = new Error(response.statusText);
16
- if (response.text.length) {
17
- return response.json().then((result)=>{
18
- error.response = result;
19
- throw error;
20
- });
21
- } else {
22
- throw error;
23
- }
14
+ return response.json().then((result)=>{
15
+ error.response = result;
16
+ throw error;
17
+ });
24
18
  }
25
19
  }
26
20
 
21
+ function _parseJSON(response) {
22
+ return response.text().then(function(text) {
23
+ return text ? JSON.parse(text) : {}
24
+ });
25
+ }
26
+
27
27
  function _invokeFetch(url,props) {
28
28
  if(!url) {
29
29
  throw new Error("fetch:Missing Parameter - URL");