
META-INF.resources.js.utils.getAllPicklists.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.frontend.data.set.admin.web
Show all versions of com.liferay.frontend.data.set.admin.web
Liferay Frontend Data Set Admin Web
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
import {fetch} from 'frontend-js-web';
import {DEFAULT_FETCH_HEADERS} from './constants';
import openDefaultFailureToast from './openDefaultFailureToast';
import {IPickList} from './types';
export default async function getAllPicklists(
page: number = 1,
items: IPickList[] = []
) {
const response = await fetch(
`/o/headless-admin-list-type/v1.0/list-type-definitions?pageSize=100&page=${page}`,
{
headers: DEFAULT_FETCH_HEADERS,
}
);
if (!response.ok) {
openDefaultFailureToast();
return [];
}
const responseJSON = await response.json();
items = [...items, ...responseJSON.items];
if (responseJSON.lastPage > page) {
items = await getAllPicklists(page + 1, items);
}
return items;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy