I want to get data from api (having basic authentication). I'm passing username and password but still I'm getting unauthorized error. How to resolve unauthorized error.api sending json data but I'm not able access it .
Code:
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.name}}</td>
<td>{{ x.city }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get('https://example.com/node1', {
headers: { 'Authorization': 'user1:user1@123' }
}).then(function (response) {$scope.names = response.data.records;});
});
</script>
</body>
</html>
console.log
in the response function and share it. – suzo 22 hours ago[username:password]
base64 encoded. Has your question now changed to how to encode the password? – Claies 21 hours ago