boilerplate for a ajax call with promise in angular