簡體   English   中英

獲取http發布請求正文AngularJS

[英]Get the http post request body AngularJS

我想知道如何在AngularsJS中獲取HTTP POST請求的正文。

事實是,我有一個網站將一個http請求發布到mywebsite,其中包含我想在我的有角度的應用程序中獲取和處理的正文中的信息。

有人有解決方案嗎? 在角度上,我僅成功獲得了請求的參數,但沒有成功獲得主體。

謝謝。

您可以在瀏覽器控制台中打印完整的請求和響應。

angular.module('interceptors.httpInterceptors',[])

.factory('httpInterceptors', [function () {
  return {
    request: function (config) {
      console.log(angular.toJson(config));   
      return config;
    },
    response: function (response) {
      console.log(angular.toJson(response));
    },
    responseError: function(rejection) {
    }    

  };
}])

.config(['$httpProvider', function ($httpProvider) {
  $httpProvider.interceptors.push('httpInterceptors');
}]);

暫無
暫無

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

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