1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/fetchers/piece_list_fetcher.js

30 lines
778 B
JavaScript
Raw Normal View History

import fetch from 'isomorphic-fetch';
import AppConstants from '../constants/application_constants';
import FetchApiUtils from '../utils/fetch_api_utils';
2015-05-18 18:00:12 +02:00
2015-05-19 17:16:01 +02:00
let PieceListFetcher = {
2015-05-19 17:01:28 +02:00
/**
* 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,
2015-05-19 17:01:28 +02:00
pageSize,
search,
ordering
});
return fetch(AppConstants.baseUrl + 'pieces/' + params, {
headers: {
2015-05-19 17:01:28 +02:00
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64
}
}).then((res) => res.json());
2015-05-18 18:00:12 +02:00
}
};
export default PieceListFetcher;