configure angularjs module to send patch request

前端 未结 1 1210
后悔当初
后悔当初 2020-12-16 17:44

I am totally new to AngularJs. I am trying to send a PATCH request using Angularjs to Django Tastypie API\'s. My code is

var module = angular.module(\'myAp         


        
相关标签:
1条回答
  • 2020-12-16 18:19

    Your error doesn't make sense based on the code you're showing, but 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). Here's 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)
提交回复
热议问题