Revise code snippet with typical usage of $http