Skip to content

Commit

Permalink
Merge pull request #455 from eltrino/master
Browse files Browse the repository at this point in the history
Added auth options to fetch calls
  • Loading branch information
mertkahyaoglu authored Mar 21, 2018
2 parents db3bd5c + c038321 commit 0c5e7fa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ducks/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const putDocument = (collection, directory, filename) => (
export const deleteDocument = (collection, directory, filename) => dispatch => {
return fetch(documentAPIUrl(collection, directory, filename), {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: DELETE_DOCUMENT_SUCCESS });
Expand Down
1 change: 1 addition & 0 deletions src/ducks/datafiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const putDataFile = (
export const deleteDataFile = (directory, filename) => dispatch => {
return fetch(datafileAPIUrl(directory, filename), {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: DELETE_DATAFILE_SUCCESS });
Expand Down
1 change: 1 addition & 0 deletions src/ducks/drafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const putDraft = (mode, directory, filename = '') => (
export const deleteDraft = (directory, filename) => dispatch => {
return fetch(draftAPIUrl(directory, filename), {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: DELETE_DRAFT_SUCCESS });
Expand Down
1 change: 1 addition & 0 deletions src/ducks/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const putPage = (directory, filename) => (dispatch, getState) => {
export const deletePage = (directory, filename) => dispatch => {
return fetch(pageAPIUrl(directory, filename), {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: DELETE_PAGE_SUCCESS });
Expand Down
2 changes: 2 additions & 0 deletions src/ducks/staticfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const uploadStaticFiles = files => dispatch => {
return fetch(staticfileAPIUrl(file.name), {
method: 'PUT',
body: payload,
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: PUT_STATICFILE_SUCCESS });
Expand Down Expand Up @@ -74,6 +75,7 @@ export const uploadStaticFiles = files => dispatch => {
export const deleteStaticFile = filename => dispatch => {
return fetch(staticfileAPIUrl(filename), {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data => {
dispatch({ type: DELETE_STATICFILE_SUCCESS });
Expand Down
4 changes: 3 additions & 1 deletion src/utils/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
* @return {Function} dispatch
*/
export const get = (url, action_success, action_failure, dispatch) => {
return fetch(url)
return fetch(url, { credentials: 'same-origin' })
.then(res => res.json())
.then(data =>
dispatch({
Expand Down Expand Up @@ -52,6 +52,7 @@ export const get = (url, action_success, action_failure, dispatch) => {
export const put = (url, body, action_success, action_failure, dispatch) => {
return fetch(url, {
method: 'PUT',
credentials: 'same-origin',
body,
})
.then(res => res.json())
Expand Down Expand Up @@ -88,6 +89,7 @@ export const put = (url, body, action_success, action_failure, dispatch) => {
export const del = (url, action_success, action_failure, dispatch) => {
return fetch(url, {
method: 'DELETE',
credentials: 'same-origin',
})
.then(data =>
dispatch({
Expand Down

0 comments on commit 0c5e7fa

Please sign in to comment.