I am Newbie to angular js. Here I am trying to call API from rails server with "http://localhost:3000/". I got error for
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'
I have added 'CORS' chrome extension to fix it. Now the problem is my request is passing to localhost:3000 as [OPTIONS], and I want it as get request.
'use strict';
angular.module('dayton')
.service('foodCategoryService', ['$http', '$window', 'authService', 'Upload',
function($http, $window, authService, Upload){
var field = {};
field.getFields = function (){
console.log("---------foodCategoryService")
return $http.get('http://localhost:3000/api/list_food_category', {
headers: {Authorization: authService.getToken()}
})
.then(function(response) {
return response;
}, function(x) {
$scope.authError = 'Server Error';
});
};
return field;
}]);
ActionController::RoutingError (No route matches [OPTIONS] "/api/list_food_category"):
Any help is going to be appreciated
localhost
right? – M. Junaid Salaat