From 03f09b8c832c941d3b877042d348658006f5e9c5 Mon Sep 17 00:00:00 2001 From: vrde Date: Tue, 16 Jun 2015 13:48:48 +0200 Subject: [PATCH] Rename fetch to requests to avoid name clashing --- js/app.js | 6 ++++-- js/components/ascribe_forms/form_delete_edition.js | 6 +++--- js/components/ascribe_forms/form_piece_extradata.js | 6 +++--- .../form_remove_editions_from_collection.js | 6 +++--- js/fetchers/edition_fetcher.js | 4 ++-- js/fetchers/edition_list_fetcher.js | 4 ++-- js/fetchers/piece_fetcher.js | 4 ++-- js/fetchers/piece_list_fetcher.js | 4 ++-- js/fetchers/user_fetcher.js | 4 ++-- js/mixins/form_mixin.js | 6 +++--- js/utils/requests.js | 10 ++++------ 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/js/app.js b/js/app.js index c50dd902..3873e33e 100644 --- a/js/app.js +++ b/js/app.js @@ -5,17 +5,19 @@ import Router from 'react-router'; import promise from 'es6-promise'; promise.polyfill(); +import fetch from 'isomorphic-fetch'; +//require('isomorphic-fetch'); import ApiUrls from './constants/api_urls'; import routes from './routes'; -import fetch from './utils/fetch'; +import requests from './utils/requests'; let headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' }; -fetch.defaults({ +requests.defaults({ urlMap: ApiUrls, http: { headers: headers, diff --git a/js/components/ascribe_forms/form_delete_edition.js b/js/components/ascribe_forms/form_delete_edition.js index 3d81c08c..40d21a7f 100644 --- a/js/components/ascribe_forms/form_delete_edition.js +++ b/js/components/ascribe_forms/form_delete_edition.js @@ -2,7 +2,7 @@ import React from 'react'; -import fetch from '../../utils/fetch'; +import requests from '../../utils/requests'; import ApiUrls from '../../constants/api_urls'; import FormMixin from '../../mixins/form_mixin'; @@ -11,7 +11,7 @@ let EditionDeleteForm = React.createClass({ mixins: [FormMixin], url() { - return fetch.prepareUrl(ApiUrls.edition_delete, {edition_id: this.getBitcoinIds().join()}); + return requests.prepareUrl(ApiUrls.edition_delete, {edition_id: this.getBitcoinIds().join()}); }, httpVerb(){ return 'delete'; @@ -32,4 +32,4 @@ let EditionDeleteForm = React.createClass({ }); -export default EditionDeleteForm; \ No newline at end of file +export default EditionDeleteForm; diff --git a/js/components/ascribe_forms/form_piece_extradata.js b/js/components/ascribe_forms/form_piece_extradata.js index 41828120..ef58b58a 100644 --- a/js/components/ascribe_forms/form_piece_extradata.js +++ b/js/components/ascribe_forms/form_piece_extradata.js @@ -2,7 +2,7 @@ import React from 'react'; -import fetch from '../../utils/fetch'; +import requests from '../../utils/requests'; import apiUrls from '../../constants/api_urls'; import FormMixin from '../../mixins/form_mixin'; @@ -14,7 +14,7 @@ let PieceExtraDataForm = React.createClass({ mixins: [FormMixin], url() { - return fetch.prepareUrl(apiUrls.piece_extradata, {piece_id: this.props.editions[0].bitcoin_id}); + return requests.prepareUrl(apiUrls.piece_extradata, {piece_id: this.props.editions[0].bitcoin_id}); }, getFormData() { @@ -45,4 +45,4 @@ let PieceExtraDataForm = React.createClass({ } }); -export default PieceExtraDataForm; \ No newline at end of file +export default PieceExtraDataForm; diff --git a/js/components/ascribe_forms/form_remove_editions_from_collection.js b/js/components/ascribe_forms/form_remove_editions_from_collection.js index 0a268c10..99204400 100644 --- a/js/components/ascribe_forms/form_remove_editions_from_collection.js +++ b/js/components/ascribe_forms/form_remove_editions_from_collection.js @@ -2,7 +2,7 @@ import React from 'react'; -import fetch from '../../utils/fetch'; +import requests from '../../utils/requests'; import apiUrls from '../../constants/api_urls'; import FormMixin from '../../mixins/form_mixin'; @@ -11,7 +11,7 @@ let EditionRemoveFromCollectionForm = React.createClass({ mixins: [FormMixin], url() { - return fetch.prepareUrl(apiUrls.edition_remove_from_collection, {edition_id: this.getBitcoinIds().join()}); + return requests.prepareUrl(apiUrls.edition_remove_from_collection, {edition_id: this.getBitcoinIds().join()}); }, httpVerb(){ return 'delete'; @@ -32,4 +32,4 @@ let EditionRemoveFromCollectionForm = React.createClass({ }); -export default EditionRemoveFromCollectionForm; \ No newline at end of file +export default EditionRemoveFromCollectionForm; diff --git a/js/fetchers/edition_fetcher.js b/js/fetchers/edition_fetcher.js index bb995523..2d289a3e 100644 --- a/js/fetchers/edition_fetcher.js +++ b/js/fetchers/edition_fetcher.js @@ -1,6 +1,6 @@ 'use strict'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; let EditionFetcher = { /** @@ -8,7 +8,7 @@ let EditionFetcher = { * If no arg is supplied, load the current user */ fetchOne(editionId) { - return fetch.get('edition', {'bitcoin_id': editionId}); + return requests.get('edition', {'bitcoin_id': editionId}); } }; diff --git a/js/fetchers/edition_list_fetcher.js b/js/fetchers/edition_list_fetcher.js index 21ebee58..32dc445d 100644 --- a/js/fetchers/edition_list_fetcher.js +++ b/js/fetchers/edition_list_fetcher.js @@ -1,6 +1,6 @@ 'use strict'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; import { generateOrderingQueryParams } from '../utils/fetch_api_utils'; @@ -11,7 +11,7 @@ let EditionListFetcher = { */ fetch(pieceId, orderBy, orderAsc) { let ordering = generateOrderingQueryParams(orderBy, orderAsc); - return fetch.get('editions_list', { 'piece_id': pieceId, ordering }); + return requests.get('editions_list', { 'piece_id': pieceId, ordering }); } }; diff --git a/js/fetchers/piece_fetcher.js b/js/fetchers/piece_fetcher.js index a5317e5f..c7629d89 100644 --- a/js/fetchers/piece_fetcher.js +++ b/js/fetchers/piece_fetcher.js @@ -1,6 +1,6 @@ 'use strict'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; let PieceFetcher = { @@ -9,7 +9,7 @@ let PieceFetcher = { * If no arg is supplied, load the current user */ fetchOne() { - return fetch.get('piece'); + return requests.get('piece'); } }; diff --git a/js/fetchers/piece_list_fetcher.js b/js/fetchers/piece_list_fetcher.js index 2f706e15..12f4b1d8 100644 --- a/js/fetchers/piece_list_fetcher.js +++ b/js/fetchers/piece_list_fetcher.js @@ -1,7 +1,7 @@ 'use strict'; import { generateOrderingQueryParams } from '../utils/fetch_api_utils'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; let PieceListFetcher = { @@ -11,7 +11,7 @@ let PieceListFetcher = { */ fetch(page, pageSize, search, orderBy, orderAsc) { let ordering = generateOrderingQueryParams(orderBy, orderAsc); - return fetch.get('pieces_list', { page, pageSize, search, ordering }); + return requests.get('pieces_list', { page, pageSize, search, ordering }); } }; diff --git a/js/fetchers/user_fetcher.js b/js/fetchers/user_fetcher.js index c57c93d9..5120fbd9 100644 --- a/js/fetchers/user_fetcher.js +++ b/js/fetchers/user_fetcher.js @@ -1,6 +1,6 @@ 'use strict'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; let UserFetcher = { @@ -9,7 +9,7 @@ let UserFetcher = { * If no arg is supplied, load the current user */ fetchOne() { - return fetch.get('user'); + return requests.get('user'); } }; diff --git a/js/mixins/form_mixin.js b/js/mixins/form_mixin.js index 770083ec..02ad30f2 100644 --- a/js/mixins/form_mixin.js +++ b/js/mixins/form_mixin.js @@ -1,6 +1,6 @@ 'use strict'; -import fetch from '../utils/fetch'; +import requests from '../utils/requests'; import React from 'react'; import AlertDismissable from '../components/ascribe_forms/alert'; @@ -29,14 +29,14 @@ export const FormMixin = { }, post(e){ - fetch + requests .post(this.url(e), { body: this.getFormData() }) .then(this.handleSuccess) .catch(this.handleError); }, delete(e){ - fetch + requests .delete(this.url(e)) .then(this.handleSuccess) .catch(this.handleError); diff --git a/js/utils/requests.js b/js/utils/requests.js index 74477281..46f97fa9 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -1,7 +1,5 @@ 'use strict'; -import { default as _fetch } from 'isomorphic-fetch'; - import { argsToQueryParams } from '../utils/fetch_api_utils'; @@ -10,7 +8,7 @@ class ServerError extends Error {} class APIError extends Error {} -class Fetch { +class Requests { _merge(defaults, options) { let merged = {}; for (let key in defaults) { @@ -79,7 +77,7 @@ class Fetch { options = options || {}; let merged = this._merge(this.httpOptions, options); merged.method = verb; - return _fetch(url, merged) + return fetch(url, merged) .then(this.unpackResponse) .then(JSON.parse) .catch(this.handleFatalError.bind(this)) @@ -117,6 +115,6 @@ class Fetch { } -let fetch = new Fetch(); +let requests = new Requests(); -export default fetch; +export default requests;