Ionic http get not working


I trying to do a $http GET call from my ionic app . It alway getting me an error.

            withCredentials: true,
            method: 'GET',
            url : ''

       }).success(function(data, status, headers, config) {
        console.log("Authentication success" + data);
       .error(function(data, status, headers, config) {
        console.log("Authentication error");

I looked at a code pen example it works perfectly for the but if i change it to it fails.

Can someone please help solve this.


Look at your browser console log, you should see this error.

XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access.

So you should learn about CORS before doing so.

Even if you had the CORS headers in your requests, it would probably fail because the code is expecting to hit a JSON API and you’re pointting it to google home page which returns HTML.