mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
32 lines
859 B
JavaScript
32 lines
859 B
JavaScript
import fetch from 'isomorphic-fetch';
|
|
|
|
import AppConstants from '../constants/application_constants';
|
|
import FetchApiUtils from '../utils/fetch_api_utils';
|
|
|
|
|
|
let PieceListFetcher = {
|
|
/**
|
|
* Fetches a list of pieces from the API.
|
|
* Can be called with all supplied queryparams the API.
|
|
*/
|
|
fetch(page, pageSize, search, orderBy, orderAsc) {
|
|
|
|
let ordering = FetchApiUtils.generateOrderingQueryParams(orderBy, orderAsc);
|
|
|
|
let params = FetchApiUtils.argsToQueryParams({
|
|
page,
|
|
pageSize,
|
|
search,
|
|
ordering
|
|
});
|
|
|
|
return fetch(AppConstants.baseUrl + 'pieces/' + params, {
|
|
headers: {
|
|
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64
|
|
}
|
|
}).then((res) => res.json());
|
|
}
|
|
};
|
|
|
|
export default PieceListFetcher;
|