Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

How to send Username and APIKey using $http?

$
0
0

@awasl wrote:

Hi all,

I'm using the api service from this website (flightaware.com). The API is called using url like this:

http://YOUR_USERNAME:YOUR_API_KEY@flightxml.flightaware.com/json/FlightXML2/InFlightInfo?ident=AA100

I got this error "401 (Authorization Required)" when trying to get the response using $http

Here is my code:

var url = "http://MY_USERNAME:MY_API_KEY@flightxml.flightaware.com/json/FlightXML2/InFlightInfo?ident="+ident;
      console.log("URL: "+ url);
      var deferred = $q.defer();

  setTimeout(function() {
    deferred.notify('About to run.');
    
   
   $http.get(url).then(function(result){ 
         
            console.log("#####_LOCATION_#####: "+result.data);
            deferred.resolve(result.data);

        }, 

        function(err) {
             deferred.reject(err);
         }

   );


  }, 600);


  
  return deferred.promise;

  }

Please help ..

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>