1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/fetchers/piece_list_fetcher.js
2015-05-20 16:44:45 +02:00

32 lines
780 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, ordering) {
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;