mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
🔨 Refactor getFields for readability
This commit is contained in:
parent
5f3b0dcdc7
commit
b4c265aa08
|
@ -296,10 +296,10 @@ export const toLoadOptions = (items: ResourceItems, nameProperty: NameType) =>
|
|||
* Retrieve all fields for a resource, sorted alphabetically.
|
||||
*/
|
||||
export async function getFields(this: ILoadOptionsFunctions, resource: SnakeCaseResource) {
|
||||
const { fields } = await zohoApiRequest.call(
|
||||
this, 'GET', '/settings/fields', {}, { module: `${resource}s` },
|
||||
) as LoadedFields;
|
||||
const options = fields.map(({field_label, api_name}) => ({ name: field_label, value: api_name }));
|
||||
const endpoint = '/settings/fields';
|
||||
const qs = { module: `${resource}s` };
|
||||
const { fields } = await zohoApiRequest.call(this, 'GET', endpoint, {}, qs) as LoadedFields;
|
||||
const options = fields.map(({ field_label, api_name }) => ({ name: field_label, value: api_name }));
|
||||
|
||||
return sortBy(options, o => o.name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue