Colleagues, I have the following problem: when wanting to access from a controller js to an API controller just to bring a list of users, the console sends me error 404.
Service that accesses the corresponding controller, passing as parameter the name of the same (apiName)
cobra.app.factory('ResourceService', function ($resource) {
var prefix = '/FLOTA/api/';
function _getResource(apiName) {
var idParam = (apiName.indexOf(":id") >= 0 ? "" : "/:id");
var resource = $resource(apiName + idParam, { id: '@id' },
{
queryp: { method: 'PUT' },
update: { method: 'PUT' },
save: { method: 'POST', params: { id: null } },
getp: { method: 'POST', params: { id: null } }
});
return resource;
}
function getResource(apiName) {
return _getResource(prefix + apiName);
}
return {
resource: getResource
}
});
When you indicate that you access the "Users" API driver, it is where you launch the 404
cobra.app.controller('usersListController', function ($scope, LoadingService, UtilityService, ResourceService, NotificationService) {
$scope.collection = [];
$scope.displayedCollecion = [];
$scope.headers = {
username: { name: 'Usuario', visible: true },
fullname: { name: 'Nombre', visible: true }
};
var restAPI = ResourceService.resource('Users');
var errorCallback = function (result) {
LoadingService.hideLoading();
NotificationService.error(result);
}
var successGetCallback = function (result) {
$scope.collection = result;
$scope.displayedCollecion = [].concat(result);
LoadingService.hideLoading();
}
var getCollection = function () {
restAPI.query(successGetCallback, errorCallback);
}
angular.element(document).ready(function () {
getCollection();
});
});
Any guidance is appreciated!