0
我打電話的獲取API: -也能收到400錯誤(錯誤請求),同時調用API
function getvalue() {
return $http({
method: 'GET',
url: '/api/value/:number'
});
}
我打電話它在我的指令:
(function() {
'use strict';
angular.module('myApp.components')
.directive('product', product);
product.$inject = ['$http','$timeout','ApiServices'];
function product($http, $timeout, ApiServices) {
return {
restrict: 'EA',
scope: {
},
link: function (scope, el, attrs) {
scope.product = {};
scope.getproductvalue = function() {
ApiServices.getproductvalue().then(
function (response) {
scope.product.value = scope.product.a + " " +scope.product.b + " " +scope.product.c;
});
};
scope.getproductvalue();
},
templateUrl: 'js/components/misc/product.html'
};
}
})();
我不斷收到此錯誤: -
GET http://localhost:3001/api/product/ 400 (Bad Request)
我從不同的API獲取a,b,c的值。
有誰能告訴我爲什麼我一直收到這個錯誤?
壞請求指─你的要求的內容是完全一樣的API期待。因此,請首先檢查進行API調用所需的格式。 ':號碼'檢查是**字符串**還是**號碼**? –
您在API中有getvalue(),但是您在指令中調用getproductvalue()。 – rrd
10.4.1 400錯誤請求 由於格式錯誤,服務器無法理解請求。客戶端不應該在沒有修改的情況下重複請求。 –