1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00
onion/js/fetchers/piece_list_fetcher.js

37 lines
921 B
JavaScript

'use strict';
import request from '../utils/request';
import { safeMerge } from '../utils/general';
import { generateOrderingQueryParams } from '../utils/url';
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, filterBy }) {
const ordering = generateOrderingQueryParams(orderBy, orderAsc);
// filterBy is an object of acl key-value pairs.
// The values are booleans
const query = safeMerge(
{
page,
pageSize,
search,
ordering
},
filterBy
);
return request('pieces_list', { query });
},
fetchRequestActions() {
return request('pieces_list_request_actions');
}
};
export default PieceListFetcher;