AngularJS Response does not match configured parameter -
i've got problem service configuration. want display 1 user function:
$scope.findone = function() { $scope.user = users.get({ userid: $stateparams.userid }); };
but in trouble user service :( don't know, how should change code avoid angular error:
error in resource configuration action
object
. expected response contain array got {2}
here code of actual working service (without function findone working of course:))
'use strict'; angular.module('users').factory('users', ['$resource', function($resource) { return $resource('users', {}, { update: { method: 'put' }, remove: { method: 'delete', url: 'users/:id', params: {id: '@_id'} } }); } ]);
at guess, i'd users
api endpoint expecting /users/:userid
requests. code @ moment request /users?userid=nnn
. need add action get
id in url, eg
return $resource('users', {id: '@userid'}, { get: { method: 'get', url: 'users/:id', isarray: false }, // etc
you can make users/:id
default url long doesn't interfere other action configurations.