From the course: JavaScript: Ajax and Fetch
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Fix an Ajax request - JavaScript Tutorial
From the course: JavaScript: Ajax and Fetch
Solution: Fix an Ajax request
(upbeat music) - [Narrator] So the API requests in this file for Smarty Streets is broken. Now, the first thing we need to do is update the API Key. So again, because this was all in a single URL, I broke that out into a variable. Created this smartyAPIKey variable that's going to store the API Key. So you want to replace that value, I went ahead and copied my API KEY, and I'm just going to paste it in there. And so now, that API Key is concatenated with the rest of that URL, to create my request URL. So, I'm going to save that, I'm going to go to my HTML file and we'll just start by going live and checking out what things look like. So, I'm going to run a test query on Smarty Streets, and in my console. So, right here in the console I have an error, and it's specifically an error that says name not resolved. Now if I look over in the Network tab, I go back and I reload my page, and I try this again, I have a failed request, and I can see there's a problem with the auth id. But I'm…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Structure Ajax requests for performance2m 49s
-
(Locked)
View requests and responses in the browser3m 21s
-
(Locked)
Work with authorization errors2m 56s
-
(Locked)
Work with malformed requests5m 15s
-
(Locked)
Work with errors in Fetch4m 44s
-
(Locked)
Provide error fallbacks7m 15s
-
(Locked)
Challenge: Fix an Ajax request49s
-
(Locked)
Solution: Fix an Ajax request4m 29s
-
(Locked)
-
-