$http({
url: "/api/v1/login/get?username="+$scope.UserName+"&password="+$scope.Password,
method: 'GET',
data:{
'ApiKey': '645rc5dsfdf4566444e34e9b205d6f91683790927e83459e2ac8a8f3',
'UserAddress': '177.70.5.2'
},
}).then(function (response) {
$scope.data = response.data;
}).catch(function (response) {
});
С моим запросом http я передаю ApiKey и UserAddress в данных, но он не работает и переходит в catch.I также попытался поместить его в заголовки и Params, но получив то же самое? Каково решение?
Заголовок должен работать. Попробуй это:
$http({
method: 'GET',
url: '/api/v1/login/get?username='+$scope.UserName+'&password='+$scope.Password,
headers: {
'ApiKey': '645rc5dsfdf4566444e34e9b205d6f91683790927e83459e2ac8a8f3',
'UserAddress': '177.70.5.2'
}
});
Попробуйте передать ключ API и адрес пользователя в качестве заголовка вместо данных. в функции $ http ({}).
$ http ({method: 'GET', url: '/api/v1/login/get?username="+$scope.UserName+"&password="+$scope.Password', заголовки: {'ApiKey': '645rc5dsfdf4566444e34e9b205d6f91683790927e83459e2ac8a8f3', 'UserAddress': '177.70.5.2'}}).