I have been pondering over the 3 approaches to make HTTP GET REST calls with angularjs. They are $http, ngResource and restangular. I settled on $http because it is simplest and leads to the most readable code. However, my REST calls are getting complicated. I need to make nested HTTP GET requests and make sure that the requests are run in the correct sequence. The entire chain of HTTP GET requests stops if one fails.
The code will look something like this;
$http.get(url_get1).success(function(data, status, headers, config)
{
$http.get(url_get2).success(function(data, status, headers, config)
{
$http.get(url_get3).success(function(data, status, headers, config)
{
//more action
}
}
}
If the chain of HTTP requests become long, the code becomes unreadable.
Would using ngResource or restangular make the code more readable and maintainable? Or are there other ways?