Search code examples
androidionic-frameworknode-request

Use request module to download and get urls in mobile application


I made a small script that use request:

request({
  url: "http://gdata.youtube.com/feeds/api/videos?alt=json&max-results=1&q=" + encodeURIComponent(trackName),
  json: true
}, function (dataAndEvents, deepDataAndEvents, data) {
});

and now I want to port it to android using Ionic Framework. Is it possible to get and download easily urls?


Solution

  • Ionic is built on angular so you can use the $http method to request remote data.

    $http({
        url: 'http://gdata.youtube.com/feeds/api/videos',
        params: {
          alt: 'json',
          max-results: 1,
          q: trackName
        }
      })
      .success(function(data, status) {
        console.log(data);
      })
      .error(function(data, status) {
        console.log('error');
      });