I am trying to query a REST API which I have hosted locally and this should work something as follows:
http://localhost:51608/api/[email protected]
That request works and it returns a User Object with an AccessLevel property. Now I have an angular application and want to query that URL using Angular Resource. I have something as follows but the URL is not being built properly.
(function () {
"use strict";
angular
.module("common.services")
.factory("userRoleResource",
["$resource",
"appSettings",
userRoleResource])
function userRoleResource($resource, appSettings) {
return $resource(appSettings.serverPath + "/api/UserRole:email", { email: '@email'});
}
})();
I am querying the above as follows:
userRoleResource.query({ email: vm.userData.email },
function (data) {
vm.userData.accessLevel = data.AccessLevel;
});
But this is generating the request as follows:
http://localhost:51608/api/[email protected] instead of http://localhost:51608/api/UserRole?email:[email protected]
What's wrong here?