Content-Type header not being set with Angular $http

后端 未结 5 2115
逝去的感伤
逝去的感伤 2021-02-15 14:23

I\'m trying to make a cross-origin POST request using Angular $http with the following code.

//I\'ve tried setting and removing these http config options
$http.d         


        
5条回答
  •  孤独总比滥情好
    2021-02-15 15:05

    The 'Content-Type' header is not being added to the request if the data property is undefined, you can send empty string as data "" for example.

     var req = {
                    method: 'GET',
                    url: '',
                    //headers: {
                    //    'Content-Type': 'application/json;charset=utf-8'
                    //},
                    data: ""
                };
      $http(req);
    

提交回复
热议问题