Finding the AJAX/API Challenges very difficult - Where can I learn enough to get good at them?

Finding the AJAX/API Challenges very difficult - Where can I learn enough to get good at them?
0

#1

As explained in the title, i’m struggling through them using help from the forum but I really feel like I don’t have a good fundamental understanding of AJAX and API’s to do them. I’ve tried looking up lots of resources but a lot are advanced or don’t explain the right thing so I’m struggling to find a good place to learn this stuff to help me with the challenges.

Any advice from you guys?


#2

This is the part where Free Code Camo becomes challenging…

Here is a intro video -


#3

This video goes through accessing, retrieving and displaying info from a movie database API -


#4

All I know is all I know from working the challenges here at FCC. To me, it’s one of those learn by doing exercises. Find a good API with good documentation, (I think google maps is pretty well documented) and play with it in some practice code. Run it in debug mode and while the object of your API code is in scope, type in the name of the object in the console. See what it contains. That was extremely helpful to me.

good luck


#5

ye i was confused when i got to this section … and when i got it sorted i realized there wasnt much too it … was obvious but i missed it lol … found this video and after watching it i was sorted so hopefully with this plus whats above you will be too.


#6

Just keep plugging away at it. If you have a specific question about it, ask here. Be sure to let us know where you are: IE, are you getting a JSON response and you don’t know how to access data in it, or are you getting errors in your data request?

I recommend using jQuery for ajax. Here’s an example of a working jQuery ajax request to the YouTube API. You can get a key to use with this call at https://console.developers.google.com/apis/dashboard

Good luck!

	function loadVideo() {
		var myKey = "enter your key as a string here";
		var request = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&order=viewCount&publishedAfter=2016-01-01T00%3A00%3A00Z&q=teaser%7Ctrailer&type=video&videoCaption=any&videoCategoryId=24&videoEmbeddable=true&key=' + myKey;
		$.ajax({
			url: request,
			success: function (data) {
			//do stuff with data, such as display it somewhere

			}
		});
	}

#7

I completely understand where your at and am still kind of there myself but am a lot clearer now that I have worked through 4 API projects. For me learning how to use console log and putting the code on full screen (if your using code pen) and going into developer options to see the logs and/ or error messages really helped a lot. There are a lot of good tutorials on using developer tools online (assuming you don’t use them already) Also like some other people said, once you figure out a specific problem (like request denied error 504) post it here/ on reddit) until you get the hang of it.


#8

Thanks everyone for your help. I think where I’m getting stuck is with the API, I don’t think I’m calling it right or something as I don’t seem to be getting anything from my get request. Here’s my code

> $(document).ready(function() {

> function getWeather() {
> $.ajax ({
>   type: "GET",
>   dataType: "json",
>   url: "https://crossorigin.me/api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid=19c9b893457b8f5ea0d0d040c080d04d",
>   success: function(data) {
>     console.log(data);
>     $(".theWeather").html(data.weather);
>   }
>     
> });
> }

> });

I find the whole API’s thing very confusing, not sure if im even copying the right url :confused: This is the website I used - https://openweathermap.org/current