Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let skip = currentPage * pageSize
let spaceId = utils.getCookie("X-Space-Id");
let authToken = utils.getCookie("X-Auth-Token");
let userId = utils.getCookie("X-User-Id")
const endpoint = `${service}/api/odata/v4/${spaceId}/${objectName}`;
const requestInit = ()=>{
return {
headers: {
'X-Auth-Token': authToken,
'X-User-Id': userId
}
}
}
const baseQuery = Odata.ODataV4QueryProvider.createQuery(endpoint, requestInit);
let query = baseQuery.skip(skip || 0)
if(pageSize){
query = query.top(pageSize)
}
if($select){
query = query.select(...$select)
}
if(options.filters){
options.filters.forEach((element: any) => {
query = query.filter((p: any) => p[element.operation](element.columnName, element.value));
});
}
let results = await query.getManyAsync();
return results