Good day! There is a JSON data file. Trying to get data from a JSON file, the error console gives:

Error: undefined is not an object (evaluating '$ http.get')

JSON example:

{ "variantA": { "sumInsuredThirty": [ { "DAYFROM": 1, "DAYTO": 3, "TARIF": 2 }, { "DAYFROM": 4, "DAYTO": 5, "TARIF": 2 }, { "DAYFROM": 6, "DAYTO": 8, "TARIF": 4 } } 

This is how I get data from JSON:

 $http.get('/JSON/rates.json').success(function(data) { $scope.rates = data; }); 

Tell me, what is the error? JSON file validation passes. Thank you in advance!

  • missing closing "]" and "}" - Igor
  • @Igor, closing "]" and "}" in the source is. This is just a piece for example. JSON is being tested for validity. The syntax is correct. - P.Shustenko
  • Error here - Error: undefined is not an object (evaluating '$http.get') - user236014

2 answers 2

Error: undefined is not an object (evaluating '$ http.get')

You have not injected / incorrectly injected the $http service, you have it undefined .

    See the contents of the data, which returns the service $http . There should be the following:

     $http.get('/JSON/rates.json').success(function(data) { $scope.rates = data.data; });