I am calling an get api:-
function getvalue() {
return $http({
method: 'GET',
url: '/api/value/:number'
});
}
I am calling It in my directive:
(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'
};
}
})();
I keep getting this error:-
GET http://localhost:3001/api/product/ 400 (Bad Request)
I am getting the value of a,b,c from different api.
Can anyone tell me why I keep getting this error?
I think you have misunderstand with angular rout URL and API calling URL.
Your http URL format should be
url: '/api/value ? number = '+18
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.