refactoring API example using Angular