Im trying to learn angularJS. I'm trying to fetch the data from an API that gives artists' data in JSON format. What I'm trying to do is to fetch the name entered in the textbar and then just show the information received as JSON. The format that the API accepts is url/artistname + app id as request, where artistname is the input. The people who's API im trying to use have given me a valid app code, which is stored in the var id. I've written the following code so far, any help would be appreciated. Thanks!
var myApp = angular.module('myApp', []);
myApp.controller('UserCtrl', function($scope,$http){
$scope.user = null;
var id = "my secret id comes here";
var name = $scope.searchText;
$scope.getByID = function() {
$http.get("https://rest.bandsintown.com/artists/" + name + id)
$scope.user = response;
console.log(response)
}
});
Next, the html code is:
<body ng-app="myApp">
<div ng-controller="UserCtrl">
Search : <input type="text" placeholder="Search Employees" ng-model="searchText"/> <br/><br/>
<button ng-click="UserCtrl.getByID()">Submit</button>
</body>
Thank you and sorry if this is a newbie question, I am indeed a newbie!