Attempting to pass JSON body for deletion through angular JS -- 4
£10-20 GBP
Cerrado
Publicado hace alrededor de 4 años
£10-20 GBP
Pagado a la entrega
Attempting to pass JSON body for deletion through angular JS
I've currently got an endpoint that relies on a JSON body in order for deletion to happen. This is the following code:
if ([login to view URL] > 0) {
var deleteRequest = [];
for (var i = 0; i < [login to view URL]; i++) {
var service = {};
[login to view URL] = $[login to view URL][toDeleteService[i]].serviceId;
[login to view URL](service);
}
var deleteUrl = "api/class/" + $scope.targetEntity.serviceId+ "/student";
await asyncDeleteUrl(deleteUrl, deleteRequest);
}
async function asyncDeleteUrl(deleteUrl, toBeDeleted) {
return new Promise(function (resolve, reject) {
$[login to view URL](deleteUrl, toBeDeleted)
.then(function (response) {
resolve(response);
},
function (errorResponse) {
reject(errorResponse);
$[login to view URL]('Bad Modification Interrupted', errorResponse);
});
});
}
I keep getting an error saying the required rest body is missing but I'm not sure why that would be the case. Any help would be appreciated, thank you.
Hi,
I am full stack developer that has more than 8 years of experience.
I have inspected your code, if this is all the code that you are using , it looks like you send "deleteRequest" parameter as an empty array to "asyncDeleteUrl" function. It may the reason of the error
I think what your are trying to do is push the service object that you created inside the loop in the delete request, because with the current code that you are using the deleteRequest array is empty.