Home Why is my code throwing [$http:badreq] error?
Reply: 0

Why is my code throwing [$http:badreq] error?

user1000
1#
user1000 Published in June 21, 2018, 8:40 am

I am trying to fetch some JSON data using the given URL. I can't understand why it's not working. I went through angular docs and other resources but as I am new to angular, am finding it difficult to find out the error. Can someone help me, please?

My code.

var app = angular.module('mainApp', []);

app.controller('mainController', ['$http', function ($http){
var self = this;


this.matches = [];
console.log(this.matches);

this.basrUrl = "https://raw.githubusercontent.com/openfootball/football.json/master/2015-16/en.1.json";

this.loadAllMatches = function(){   
    $http({
        method: "GET",
        url: self.baseUrl,
    }).then(function successCallback(response){
        console.log(response);
        self.matches = response.data.matches;
        console.log(self.matches);

      },function errorCallback(response){
        alert("Some Error occurred, check the console");
        console.log(response);

      });
    }   
}]);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.542348 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO