1

I am creating an application related to cricket match information in angular. Am getting problem in fetching api response. you can check api response here. Console is showing error, please check here

Here is my code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>

<body>
<div class="container" ng-app="cricApp" ng-controller="cricCtrl">
<div class="form-group">
<h2>Your result</h2>
<table class="table table-striped">
    <thead>
      <tr><th colspan="4"><h4>Cricket Match Info</h4></th></tr>
      <tr>
      <th>Sno</th>
      <th>unique_id</th>
      <th>description</th>
      <th>title</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="match in matchList | filter: nameFilter">
        <td>{{$index + 1}}</td>
        <td>
          {{match.unique_id}}
        </td>
         <td>{{match.description}}</td>
        <td>{{match.title}}</td>
      </tr>
    </tbody>
  </table>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script>
angular.module('cricApp', []).
controller('cricCtrl', function($scope, $http) {
$scope.matchList = [];
    $http.get("http://cricapi.com/api/cricket").then(function (response) {
        console.log(response);
        $scope.matchList = response.data;
    });
}
);
</script>
</body>
</html>
3
  • Can you please post your console.log(response); response? Commented Aug 4, 2016 at 11:56
  • In the first line of the error message that you are getting you will see a URL (http://errors.angularjs....), if you click on that URL you will get not information about the error you are getting Commented Aug 4, 2016 at 11:56
  • remove that filter from there and try Commented Aug 4, 2016 at 11:56

1 Answer 1

4

your code is fine just replace

 $scope.matchList = response.data;

with

$scope.matchList = response.data.data;

because actual data is coming in data inside response.data.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.