-
Notifications
You must be signed in to change notification settings - Fork 141
translate: http.md #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed it! |
728d8ac to
1f998e6
Compare
|
CLAs look good, thanks! |
aio-ja/content/guide/http.md
Outdated
| With `HttpClient`, `@angular/common/http` provides a simplified API for HTTP functionality for use with Angular applications, building on top of the `XMLHttpRequest` interface exposed by browsers. | ||
| Additional benefits of `HttpClient` include testability support, strong typing of request and response objects, request and response interceptor support, and better error handling via apis based on Observables. | ||
| `HttpClient` は、 `@angular/common/http` の中に含まれていて、Angularアプリケーションで使われるHTTPのためのシンプルなAPIです。ブラウザが公開している `XMLHttpRequest` インターフェースの上にAPIを築きます。 | ||
| さらに `HttpClient` は、リクエストやレスポンスオブジェクトの強力な型付け、リクエストとレスポンスのインターセプタ、そしてオブザーバブルに基づくAPIを通してエラーハンドリングすることで、テストを簡単にします。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observableはそのままでよいでしょう
aio-ja/content/guide/http.md
Outdated
| appモジュールに `HttpClientModule` をインポートすると、コンポーネントやサービスに `HttpClient` を注入できるようになります。 | ||
|
|
||
| ## Making a request for JSON data | ||
| ## JSONデータのリクエストを作る |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONデータを要求する
aio-ja/content/guide/http.md
Outdated
|
|
||
| You can, however, tell `HttpClient` what type the response will be, which is recommended. | ||
| To do so, first you define an interface with the correct shape: | ||
| とはいえ、レスポンスがどんな型であるか `HttpClient` に教えることができます。そのために、まず次のように正しい型のインターフェースを定義します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とはいえ -> しかしながら
aio-ja/content/guide/http.md
Outdated
| // ヘッダーを読める | ||
| console.log(resp.headers.get('X-Custom-Header')); | ||
| // And access the body directly, which is typed as MyJsonData as requested. | ||
| // ボディに直接アクセスするとリクエストしたようにMyJsonData型である。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ボディに直接アクセスすると、要求どおりMyJsonData型である
aio-ja/content/guide/http.md
Outdated
| ``` | ||
|
|
||
| As you can see, the resulting object has a `body` property of the correct type. | ||
| ご覧のように、結果として得られるオブジェクトは正しいタイプの `body` プロパティを持っています。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正しい型の
aio-ja/content/guide/http.md
Outdated
| 外部依存関係と同様に、HTTPバックエンドは良いテストプラクティスの一環としてモックされる必要があります。 `@angular/common/http` は、このようなっモックを簡単に設定するテストライブラリ `@angular/common/http/testing` を提供します。 | ||
|
|
||
| ### Mocking philosophy | ||
| ### モックのフィロソフィー |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
モックの思想
aio-ja/content/guide/http.md
Outdated
| それでおしまいです。これでテストの過程で行われたリクエストは、通常のバックエンドの代わりにテストバックエンドに当たるでしょう。 | ||
|
|
||
| ### Expecting and answering requests | ||
| ### リクエストのexpectとanswer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
リクエストの待ち受けと応答
aio-ja/content/guide/http.md
Outdated
| // this URL, so it will match and return a mock request. The mock request | ||
| // can be used to deliver a response or make assertions against the | ||
| // request. In this case, the test asserts that the request is a GET. | ||
| // そのURLのリクエストがなかった場合、または複数のリクエストが一致した場合、expectOne()はスローする |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expectOne()は例外を投げます
aio-ja/content/guide/http.md
Outdated
| ``` | ||
|
|
||
| #### Custom request expectations | ||
| #### リクエストのカスタムエクスペクト |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
独自のリクエスト待ち受け
aio-ja/content/guide/http.md
Outdated
| ``` | ||
|
|
||
| Just as with the `expectOne()` by URL in the test above, if 0 or 2+ requests match this expectation, it will throw. | ||
| 上記のテストではURLによる `expectOne()` と同様に、0または2以上のリクエストがこの期待値に一致すると、スローされます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
例外を投げます
|
翻訳ありがとうございます!いくつかの部分で修正をお願いします 🙇 全体を通して、ソースコード中のコメントも「〜です、ます」調に統一していただけますか? |
1f998e6 to
08c62b5
Compare
08c62b5 to
8387736
Compare
|
@lacolaco レビューありがとうございました。修正したので、確認お願いします:bow: |
|
修正ありがとうございました! |
#49 です:bow: