1

I have a GET endpoint like the following:

http://test.com/api/test/1234

where 1234 is the value of the key. The URL only looks for the value of the key and not the key name itself.

I tried using:

var params = {'': vehicleId};

to set the parameter, but the resulting URL looks like:

http://test.com/api/test?=237819

How do I hit my API in the above format using Angular's $Resource .get() method?

1
  • Can you accept the answer if you feel it was of help? This would encourage others to help in the community. :) Commented May 6, 2014 at 1:51

1 Answer 1

2

The resource has to be defined as:

var Vehicle = $resource('/api/test/:vehicleId', { vehicleId: '@id' });

and then the resource can be used as:

Vehicle.get({vehicleId: 1234}, function(data) {
    console.log("data", data);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.