rdiazroman
rdiazroman

Reputation: 429

Soundcloud ajax response not reached

I'm executing this query to get an user in SoundCloud. I can see that the call is correctly done in Chrome network tab, after a click, however, it doesn't reach the javascript alert. So I can't retrieve the JSON response and add it to the DOM.

<script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script>
<script>
  SC.initialize({
    client_id: '067320efe29b7da263fd8bb093911116',
    redirect_uri: 'trofeosbalbino.com/beonerecords'
});

$("#embedTrack").click(function() {
    SC.get('/users', {q: 'beonerecords'}, function (users) {
      alert(users);  
    });
});
</script>

Upvotes: 1

Views: 69

Answers (1)

Jacques Marais
Jacques Marais

Reputation: 2756

When using the SoundCloud API in a client side web application, you should use the SC.connect() method to authenticate the application. Try something such as the following:

SC.initialize({
  client_id: '067320efe29b7da263fd8bb093911116',
  redirect_uri: 'http://trofeosbalbino.com/beonerecords'
});

$("#embedTrack").click(function() {
    SC.connect().then(function(){
      SC.get('/users', {q: 'beonerecords'}, function (users) {
        return users;
      });
    }).then(function(users){
      alert(users);
    });
});

Upvotes: 1

Related Questions