separated REST calls and page functionality for categories in javascript