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 trialshobha gunupuru
1,137 Pointshow to write the code when there is api_key given
how to write the getJson method when api key has to be used
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsYou would just pass api_key
as another parameter/option. Getting that API key may be a longer process though:
shobha gunupuru
1,137 Points'''$.ajax({ type :'GET', url :'http://hire.lcdevelopment.com/api/users api_key=gunupuru.shobha@gmail.com',
});
those are url and apikey given how do i write the code now
Iain Simmons
Treehouse Moderator 32,305 PointsHave a look at the jQuery documentation for $.getJSON.
Basically, the pattern is you pass the url
, data
and success
callback function. In the Flickr API example, these corresponded to variables flickrAPI
, flickrOptions
, and displayPhotos
:
$.getJSON(flickrAPI, flickrOptions, displayPhotos);
Rename the variables to something suiting your needs, and replace as necessary (your url
above could replace the flickrAPI
variable, for example).
Have a try, see how you go!
shobha gunupuru
1,137 Pointsshobha gunupuru
1,137 Pointshow to pass api_key as another parameter or option. can you please explain with a code sample
Iain Simmons
Treehouse Moderator 32,305 PointsIain Simmons
Treehouse Moderator 32,305 PointsI just mashed the keyboard, so that's not a real API key of course, but it'd more or less be this:
A full example would require looking at the structure of the response and changing how you're using it in the output HTML, etc. And would probably need other parameters/arguments/options passed to the API.