I am trying to use AngularJS $resource to DELETE data from my server. However, when I write the result to console, I do not see the data.
However, when I go to "Network" in Chrome's console, I see the DELETE in the Name Path left column. When I click on the "info, I see five tabs on the right panel. Under the Preview and Response tabs, I see the correct data. I just don't know how to see or retrieve that in my Javascript.
Here is the javascript service code:
var MyServices = angular.module('MyServicesName', ['ngResource']);
MyServices.factory('AAAService', function($resource) {
return $resource(serverBaseUrl + 'users/:userId/Video/:videoId/', {userId: '@userId', videoId: '@videoId'}, {
show: {method: 'GET'},
update: {method: 'PUT', params: {id: '@id'}},
delete: {method: 'DELETE', isArray:false}
});
});
And the Controller:
quizcatControllers.controller('BBBCtrl', ['$scope', '$stateParams', '$http', 'AAAService',
function($scope, $stateParams, $http, AAAService) {
$scope.deleteQuestion = function(user, videoId) {
AAAService.delete({userId: user, videoId: videoId}, function(a, b) {
console.log(a);//Expect to print the data
console.log(b);
});
Can someone suggest how my code should be changed so that I can fetch the data from the response? Although my response data is not in array format I would like to know how to do it for both: array and not array style.
What should be the proper names instead of a and b on the following line:
AAAService.delete({userId: user, videoId: videoId}, function(a, b) {
UPDATE:
This is the result I get in the success callback for the parameter returnValue:
0: "S"
1: "u"
2: "c"
3: "e"
4: "s"
5: "s"
$promise: Object
$resolved: true
proto: Resource