-1

I am trying to get all of the questions with the tag ipv4 in stackoverflow using the api of stackoverflow. But i have the following error No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

I have registered my app at stack exchange. But i dont know how to authentify it.

Can you help, a tutorial or documentation is more than welcome

Here is my code for the moment :

$http.get( "http://api.stackexchange.com/docs/questions#order=desc&sort=activity&tagged=ipv4&filter=!BHMIbze0EPheMk572h0ktETsgnphhU&site=stackoverflow&run=true")
            .success(function(data) {
                console.log(data);
            });

1 Answers1

1

The url that is making the request is incorrect You are connected correctly to the api url ??

Here is a example

$.ajax({
    url:'https://api.stackexchange.com/2.2/questions?order=desc&sort=activity&tagged=ipv4&site=stackoverflow&filter=!BHMIbze0EPheMk572h0ktETsgnphhV',
    complete: function (response) {
        $('#output').html(response.responseText);
    },
    error: function () {
        $('#output').html('Bummer: there was an error!');
    },
});

http://jsfiddle.net/heanfig/v5hLzmud/1/

  • Andres thank you so much for your answer. But what do you mean by You are connected correctly to the api url? Iam pretty much new to angularjs and web development as a whole. – Mikyas TADESSE Dec 02 '16 at 15:02
  • What I mean is that the url to which you are making the wrong request sent you an angular snippet using the stackoverflow api And the url to which you are requesting returns HTML and generates the cross-origin error PS: sorry my bad english :-O angularjs + stackoverflow api http://jsfiddle.net/heanfig/vsjy89bu/1/ – Herman Andres Figueroa Dec 02 '16 at 15:07