Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I have some web services that I want to call. $resource or $http, which one should I use?

$resource: https://docs.angularjs.org/api/ngResource/service/$resource

$http: https://docs.angularjs.org/api/ng/service/$http

After I read the two above API pages I am lost.

Could you please explain to me in plain English what is the difference and in what situation should I use them? How do I structure these calls and read the results into js objects correctly?

1 Answer

0 votes
by (106k points)

To call the web services $resource or $http you can use the following ways:-

The $http is for general purpose AJAX. In most cases, this is what you'll be using. With $http you're going to be making GET, POST, DELETE type calls manually and processing the objects they return on your own. Whereas the $resource wraps $http for use in RESTful web API scenarios.

Related questions

+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...