Skip to content

Commit

Permalink
fix(networkHelpers): allow no token
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienharnay authored and Titozzz committed Mar 19, 2018
1 parent b1982e3 commit 330c851
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/internals/network/getDefaultNetworkHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const DEFAULT_NETWORK_HELPERS = {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${this.getToken()}`,
...(this.getToken && this.getToken()
? { Authorization: `Bearer ${this.getToken()}` }
: {}),
},
};
},
Expand All @@ -14,8 +16,10 @@ const DEFAULT_NETWORK_HELPERS = {
method: 'PATCH',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${this.getToken()}`,
'Content-Type': 'application/json',
...(this.getToken && this.getToken()
? { Authorization: `Bearer ${this.getToken()}` }
: {}),
},
body: JSON.stringify(body),
};
Expand All @@ -25,8 +29,10 @@ const DEFAULT_NETWORK_HELPERS = {
method: 'PUT',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${this.getToken()}`,
'Content-Type': 'application/json',
...(this.getToken && this.getToken()
? { Authorization: `Bearer ${this.getToken()}` }
: {}),
},
body: JSON.stringify(body),
};
Expand All @@ -36,8 +42,10 @@ const DEFAULT_NETWORK_HELPERS = {
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${this.getToken()}`,
'Content-Type': 'application/json',
...(this.getToken && this.getToken()
? { Authorization: `Bearer ${this.getToken()}` }
: {}),
},
body: JSON.stringify(body),
};
Expand All @@ -47,7 +55,9 @@ const DEFAULT_NETWORK_HELPERS = {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${this.getToken()}`,
...(this.getToken && this.getToken()
? { Authorization: `Bearer ${this.getToken()}` }
: {}),
},
};
},
Expand Down

0 comments on commit 330c851

Please sign in to comment.