簡體   English   中英

angularjs $ http強制內容類型頭

[英]angularjs $http is forcing Content-type header

我試圖發布一個表單,使用此:

$http({
                url: authUrl,
                method: 'POST',
                data: params,
                headers: {
                    'Content-type': 'application/x-www-form-urlencoded',
                    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
                }
            }).success($scope.getEmailData).error($scope.httpError);

但是當我簽到提琴手時,內容類型作為Content-Type: application/json;charset=UTF-8 application/x-www-form-urlencoded發送Content-Type: application/json;charset=UTF-8 application/x-www-form-urlencoded

這是一個錯誤還是我錯過了什么?

嘗試使用Content-Type而不是Content-type作為密鑰。

此外,如果未定義params ,則可能導致問題。 嘗試將數據設置為'' 即。

$http({
            url: authUrl,
            method: 'POST',
            data: params || '',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
            }
        }).success($scope.getEmailData).error($scope.httpError);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM