Using one function for both handleApiList and handleApiTree