0

I'm trying to modify the following answer:

Is it possible to do

app.factory('Facedetect',function($resource) {

  return {

    query: function(image_url) {
      return $resource('skyBiometry/facedetect/:_id', {_id:"@_id"}, { //changes here
             query: { method: 'GET', params: {imageUrl:image_url}, isArray: false }
      }).query();

    }
  }
});

The change I'd like to make would be to do the following query:

skyBiometry/facedetect/1?image_url="some_url.com"

I've tried many variations of calling this new function, such as:

Facedetect.query("_id":1,"some_url.com")
Facedetect.query({"_id":1},"some_url.com")

But neither seem to work. Is there a way to do this? Or am I misusing angularjs factory?

nodel
  • 471
  • 6
  • 22

1 Answers1

0

The only issue I can see here is that you aren't providing a parameter to the query function to provide an id argument to. You should do:

query: function(id, image_url) {
  return $resource('skyBiometry/facedetect/:_id', {_id:"@_id"}, { //changes here
         query: { method: 'GET', params: {_id: id, imageUrl: image_url}, isArray: false }
  }).query();

}

Then, call it like before:

Facedetect.query(1,"some_url.com")
Devin Fields
  • 2,066
  • 1
  • 10
  • 18