Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Building with AngularJS and APIs

David Trejo
David Trejo
19,914 Points

API Parameters

Hello, This is a great video and it has been very helpful for me how to use Angular with APIs. I sort of wanted to take a step further and try to add more to the existing project in the video. One of the things that I don't quite understand is how to put the Dribbble's API parameters into the link.

https://api.dribbble.com/shots/popular?callback=JSON_CALLBACK

http://developer.dribbble.com/v1/shots/#list-shots I am looking at Dribbble's API Documentation, and I am looking at the "Shots" section. I see that you can add parameters into the link using list, timeframe ,date,sort. How would I add those parameters into the link correctly.

http://developer.dribbble.com/v1/users/#get-a-single-user Also, under "Users" section, I wanted to figure out how to get a single user information. I see the says GET /users/:user. Looking at it, I am thinking that this would be https://api.dribble.com/users/user?callback=JSON_CALLBACK. Unfortunately, it is not retrieving anything back.

What are the standard rules working with APIs using JSONP?

1 Answer

Hi David,

Are you replacing JSON_CALLBACK with the name of your actual callback function? If I remember this correctly, you put the name of a function in there, and then of course you actually need a function that has that same name to execute when the JSONP payload is returned.

So instead of

https://api.dribbble.com/shots/popular?callback=JSON_CALLBACK

you would have

https://api.dribbble.com/shots/popular?callback=myCallbackFunction

as the URL. And then you would need a function in there with the same name

var myCallbackFunction = function (data){
    console.log(data)   //or whatever you're going to do with data
}

I hope I'm not too far off the mark here.

  • Gene