JS Lesson 4: getGithubInfo should not return the xmlhttp object

Open
#451 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
32/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
documentation

Research direction

Start with js/lesson4/tutorial.md and inspect the getGithubInfo example and its surrounding lesson context. Resolve the intended success and failure return contract with maintainers, then update the tutorial so the example no longer exposes the XMLHttpRequest object and clearly shows the resulting behavior.

Written by the indexing model from the issue text.

Description

Where

The tutorial https://github.com/codebar/tutorials/blob/gh-pages/js/lesson4/tutorial.md

What

The code block

function getGithubInfo(username) {
  var url = 'https://api.github.com/users/' + username;

  var xmlhttp = new XMLHttpRequest();
  xmlhttp.open('GET', url, false);
  xmlhttp.send();

  return xmlhttp;
}

returns the xmlhttp object. I would argue that this is bad practice and the function should return only the data or a signifier of failure, for example throwing an error. The reason I think this is bad practice is that it as a function should only give data, and should not let its functionality "leak out" (sorry I am struggling to describe this well).

Am I willing to fix

Yes, I just wanted to know if people agreed with me first :)

Dominant language
JavaScript
Stars
268
Forks
240
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from codebar/tutorials

All issues in codebar/tutorials

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.