mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
Rename fetch to requests to avoid name clashing
This commit is contained in:
parent
ed3adf8f67
commit
03f09b8c83
@ -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,
|
||||
|
@ -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';
|
||||
|
@ -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() {
|
||||
|
@ -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';
|
||||
|
@ -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});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user