0

I have this three console.log calls for testing in my code:

console.log(data);
console.log(data.url);
console.log(data["url"]);

The output in the console is:

mySC.js:85 Object {}songArtist: "Kasbo" songTitle: "Kasbo - Found You (Feat. Chelsea Cutler) " thumbnail: "https://i1.sndcdn.com/artworks-000216213225-csqjf0-t500x500.jpg" url: "https://soundcloud.com/kasbomusic/found-you-feat-chelsea-cutler"__proto__: Object
mySC.js:86 undefined
mySC.js:87 undefined

Where is my error? Why I don't get the url of this object?

EDIT

These are the function calls where I pass the data

playSC(iFrame, song, false, function(data) {
  updateSongInfo(data);
});

function updateSongInfo(data) {
  updateLink(data.url);

  console.log(data);
  console.log(data.url);
  console.log(data["url"]);
}

function playSC(player, song, autoPlay, callback) {
  player.load(song, {
    auto_play: autoPlay,
    callback: function () {
      var data = getSCinfo(song);
      if(callback) {
        callback(data);
      }
    }
  });
}

function getSCinfo(song){
  var scUrl = 'https://soundcloud.com/oembed.json?maxheight=200&url='+song;
  var computedData = {};

  getAjax(scUrl, function(data) {
    var jsonData = JSON.parse(data);
    var thumbHttps = jsonData.thumbnail_url.replace(/^http:\/\//i, 'https://');
    var titleOnly = jsonData.title.split("by");

    computedData.thumbnail = thumbHttps;
    computedData.songTitle = titleOnly[0];
    computedData.songArtist = jsonData.author_name;
    computedData.url = song;
  });

  return computedData;
}
Sebastian
  • 951
  • 6
  • 21

0 Answers0