JS Lesson 4: getGithubInfo should not return the xmlhttp object

オープン
#451 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
32/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript
領域
documentation

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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 :)

主要言語
JavaScript
スター
268
フォーク
240
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codebar/tutorials のほかの issue

codebar/tutorials の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。