I have a Web API which is returning a response in JSON, in this format:
{
"email": "[email protected]",
"password": null,
"accessLevel": 2
}
I am trying to access the accessLevel field within that response, but I am getting this Angular error:
Error in resource configuration for action `query`. Expected response to contain an array but got an object (Request: GET http://localhost:51608/api/[email protected]...)
This is my Angular resource code (below), I just added the isArray false to attempt to solve the issue:
function userRoleResource($resource, appSettings) {
return $resource(appSettings.serverPath + "/api/UserRole?email=:email", { email: '@email' },
{
get: {
method: 'GET',
isArray: false
}
});
}
And this is how I am attempting to use the data:
userRoleResource.query({ email: vm.userData.email },
function (data) {
vm.userData.accessLevel = data.AccessLevel;
});