patch request using angularjs

前端 未结 1 1496
情歌与酒
情歌与酒 2020-12-29 13:05

I am working on an API using djang-tastypie as backend and AngularJs for front end. I am sending request fro CRUD using angularjs $http. GET, POST, PUT everything is fine b

相关标签:
1条回答
  • 2020-12-29 13:54

    A common issue with adding PATCH to AngularJS is that it doesn't have a default Content-Type header for that HTTP method (which is application/json;charset=utf-8 for PUT, POST and DELETE). And these are my configuration of the $httpProvider to add patch support:

    module.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.headers.patch = {
        'Content-Type': 'application/json;charset=utf-8'
    }
    }])
    
    0 讨论(0)
提交回复
热议问题