-1

How can I convert this REST call in angularJS from $http to $resource?

$http.get('https://url?&q={"last-name":"Harris"}')
  .success(function (restData) {
    $rootScope.resp = restData;
 });
halfer
  • 19,824
  • 17
  • 99
  • 186
Lee DaBord
  • 11
  • 2

2 Answers2

0

Thy this:

$resource('https://url?&q={"last-name":"Harris"}').get(function(response){});
arghtype
  • 4,376
  • 11
  • 45
  • 60
Sreehari S
  • 388
  • 1
  • 12
  • hmm, I was expecting something like $resource.get({"last-name": "Harris"}) but don't know exactly how to do that. any ideas? – Lee DaBord Jan 18 '17 at 20:27
0

I was expecting that I could simply supply additional query selection criteria using $resource, but I think the RESTful API only allows such selection through the &q= param in the url.

So, I'll use examples from the link below and build my own little factory to give me the flexibility that allows me manipulate the url and select records using any desired field, and not only by the unique record :id https://docs.angularjs.org/api/ngResource/service/$resource

Will post an update here as my understanding is further enhanced.

Lee DaBord
  • 11
  • 2