Skip to content

Commit 2c2bc54

Browse files
author
Sam Han
committed
Clarify some steps in JS lesson 4.
1 parent cda4bcd commit 2c2bc54

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

js/lesson4/tutorial.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,17 @@ First, let's create a function that does the AJAX call to the GitHub API.
123123
```js
124124
function getGithubInfo(username) {
125125
var xhr = new XMLHttpRequest();
126-
xhr.open(...);
126+
// open and then send the request
127127

128128
return xhr;
129129
}
130130
```
131+
> Set the async parameter to false so the call is synchronous.
132+
This means the browser will wait for the call to the GitHub API to finish before continuing.
133+
134+
> Otherwise you can set it to true and add the extra methods to handle the changes in `readyState` of the request.
135+
136+
> See [Mozilla Developer Network (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/onreadystatechange) for more details.
131137
132138
**Note** We want `getGithubInfo(username)` to return us the entire response, so we can check for the status and handle it when necessary.
133139

@@ -174,8 +180,11 @@ The `showUser(user)` function should:
174180
3. Add an image in `#profile .avatar`. To do that, you can use the `avatar_url`
175181
from the response.
176182

183+
> Once you have parsed the response, try using `console.log()` to see what the object looks like in the browser console.
184+
177185
> Don't forget to call `showUser()` from the function handling the keypress!
178186
187+
179188
##Publish to Github
180189

181190
Link to your Github User Finder from `index` and push your changes to Github.

0 commit comments

Comments
 (0)