Ionic: Unable access REST services using $resource

Service Code:

angular.module(‘starter.services’, [‘ngResource’])

.factory(‘filmsData’, function($resource) {
var resource = $resource(’/data/film/:id’, {id: ‘@id’}, {“getAll”: {method: “GET”, isArray:true}});
return {
getFilms: function(filmId) {
return resource.get({id:filmId});
},
save: function(film) {
film.id = 123;
return resource.save(film);
},
getAllFilms: function() {
return resource.query();
}
};
});

controllers code:

angular.module(‘starter.controllers’, [])
.controller(‘FilmsCtrl’, function($scope , filmsData) {
$scope.films= filmsData.getAllFilms();
console.log($scope.films);
})

getting error in browser:

[$promise: Object, $resolved: false]
GET http://localhost:8100/data/film 404 (Not Found) ionic.bundle.js:16185

app Folder structure

www
css
data
film
1.json
2.json
3.json
js
lib
index.html

please help to fix this issue.

looks like you are trying to read data from local json files (1.json , 2.json) . You need to give complete file name to access it. Try appending .json at the end of your url.

Yes, looks like you make wrong request, try to make request to json manually via your browser …

Thanks for your reply. the same code using only AngularJS & node.js working perfectly; without filename also able to getting the data from all json files, while trying from ionic, getting the 404 not found,