Angular.js delete resource with parameter

后端 未结 4 1707
醉酒成梦
醉酒成梦 2021-02-01 17:52

My rest api accpets DELETE requests to the following url

/api/users/{slug}

So by sending delete to a specified user (slug) the user would be de

4条回答
  •  青春惊慌失措
    2021-02-01 17:52

    Just omit the '@' in the parameter

       .factory('reportFactory', ['$resource', 'baseUrl', function ($resource, baseUrl) {
            return $resource(baseUrl + '/keys/:id', {}, {
            delete: { method: 'DELETE',
                headers: {
                    'Content-Type': 'application/json'
                },
                params: {id: 'id'} }
           })
    }]);
    

    this will give you:

      http://localhost:8080/reports/api/keys/b8a8a8e39a8f55da94fdbe6c 
    

    without the question mark

提交回复
热议问题