0

I know that HTML does not support anything other than POST and GET.

I have a app that works when I send a DELETE request via POSTMAN. But when I try with ng-submit or ng-click that calls a function delete, it does not work.

How can I achive this delete request in-code ? Is that possible to create a button that does a DELETE request ? I am using AngularJS.

This is what I have created: (index.html)

<md-button ng-click="delete()">Delete everything.</md-button>

This is the app.js that calls the function delete:

      $scope.delete = function(index) {
      var data = {
         "id" : $scope.pollData[index].id,
         "option" : $scope.pollData[index].selected
       };
      $http.delete("/polls",data).success(function(response) {
      if(response.responseCode === 0) {
        console.log("Success");
        console.log("IvanUspeh");
        $scope.hiddenrows.push(index);
      } else {
        console.log("error");
      }
    });
  };
1

1 Answer 1

0

Send your data to the with request params, syntax below.

  http.delete("/some/url", { 
        params: {
              "foo": "bar"
        }
  });

At the minute I don't think your api is accessing the request payload you're sending up.

In node/express I would access the params via

  app.delete("/some/url", (req, res) => {

         let foo = req.query.foo;
         //foo = "bar"

  });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.