when i am testing api with rest client postman, its working fine. This is the parameter.
URL: http://localhost/api2/v1/delete_item_in_order
Type : post
Body : order_id:1091, product_id:12, variant_id:20
Same thing i want to with service and controller in angularjs.
Service :
var BASEURL = 'http://localhost/api2/v1/';
sampleApp.factory('Order', function ($resource, $cacheFactory) {
return $resource(BASEURL + 'shop_orders/:id', {id: '@id'}, {
'query': {method: 'GET', cache: true},
'get': {method: 'GET'},
'deleteOrderRow' :{
method : 'POST',
url : BASEURL + 'delete_item_in_order',
params : { order_id : '@order_id', product_id : '@product_id', variant_id : '@variant_id' }
}
});
});
Controller:
Order.deleteOrderRow({order_id: od.order_id, product_id: od.product_id, variant_id: od.varient_id}, function (data) {
alert('success');
});
But this is giving error in console:
angular.js:10765 OPTIONS http://localhost/api2/v1/delete_item_in_order?order_id=1091&product_id=767&variant_id=47 (anonymous function) @ angular.js:10765r @ angular.js:10558g @ angular.js:10268(anonymous function) @ angular.js:14792r.$eval @ angular.js:16052r.$digest @ angular.js:15870r.$apply @ angular.js:16160(anonymous function) @ angular.js:23618If @ angular.js:3346Hf.d @ angular.js:3334
/#/GetDetails/1091:1 XMLHttpRequest cannot load http://localhost/api2/v1/delete_item_in_order?order_id=1091&product_id=767&variant_id=47. Response for preflight has invalid HTTP status code 404
Can anyone help me on this? What is wrong and what changes is needed in controller and/or service to make the request successful.