もしpromise が正常に解決すると、awaitpromiseは 結果を返します。 If a promise resolves normally, then await promise returns the result. Promiseは 、自身の非同期動作を完了すると、渡されたコールバック関数を実行します。When a Promise finishes with its asynchronous operations, the Promise runs the callback function you passed it. すべてのエラーが返され、promiseは フロントエンドで(エラーオブジェクトを伴って)rejectされます。 Any failures are returned and the promise is rejected on the front-end(with the error object). Promiseを使う-JavaScript|MDNPromiseは 非同期処理の最終的な完了もしくは失敗を表すオブジェクトです。 Using Promises- JavaScript| MDN A Promise is an object representing the eventual completion or failure of an asynchronous operation. Fetchにより返却されたpromiseは 、要求を行うことができない場合にrejectします。 The promise returned by fetch rejects when it's impossible to make a request.
覚えておいてください、Promiseは 1つの結果のみを持ちますが、コールバックは技術的には何度も呼ぶことができます。 Remember, a promise may have only one result, but a callback may technically be called many times. 解決または拒否されているpromiseは 、“pending”のpromise とは対照的に“settled”と呼ばれます。 A promise that is either resolved or rejected is called“settled”, as opposed to an initially“pending” promise. .Promiseは 、XRPLedgerを照会するなど、値を後ほど返す非同期操作の実行を目的としています。A Promise is designed to do an asynchronous operation that returns a value later, such as querying the XRP Ledger.Promiseは リモートサーバがヘッダーで応答するとき、完全なレスポンスがダウンロードされる前にresponseオブジェクトで解決されます。The promise resolves with a response object when the remote server responds with headers, but before the full response is downloaded.Promiseは fetchがHTTPリクエストを作るすることができなかった場合、例えばネットワークの問題やそのようなサイトがない場合にrejectします。The promise rejects if the fetch was unable to make HTTP-request, e.g. network problems, or there's no such site.Promiseは “生成コード”と“消費コード”をリンクする特別なJavaScriptオブジェクトです。A promise is a special JavaScript object that links the“producing code” and the“consuming code” together.古いコールバックAPIをラップするPromise の作成Promiseは コンストラクタを使って1から作ることもできます。 Creating a Promise around an old callback API A Promise can be created from scratch using its constructor. Promiseは 、サーバがヘッダを応答するとすぐに組み込みのResponseクラスのオブジェクトでresolveします。The promise resolves with an object of the built-in Response class as soon as the server responds with headers.Promiseは 最初から確実に終わっているので、これは奇妙です。That's strange, because the promise is definitely done from the beginning. 返されるPromiseは 、全画面モードが起動したときに解決します。 Returns a Promise which is resolved once full-screen mode has been activated. すべてのバリデーションにパスすると、データはデータベースに保存され、promiseは クライアント上でresolveされます。 If all validations pass, the data is saved to the database and the promise is resolved on the client. Asyncfunctionが例外や何らかの値をスローした場合、promiseは スローされた値で拒否されます。 When the async function throws an exception or some value, the Promise will be rejected with the thrown value. Catchがない場合、async関数f()の呼び出しによって生成されたpromiseは 拒否されます。それを処理にするには。 Catch, then the promise generated by the call of the async function f() becomes rejected. We can append. しかし、PencilsofPromiseは 、雨が降ってもそれほど騒がない屋根のある新しい学校を建てました-そして今、学校は開いたままです。子供たちは教育を受けています。 But Pencils of Promise built a new school with a roof that isn't so loud when it rains- and now school stays open. Promiseは 、then()を使用する非同期コード・ブロックのすべての例外(明示的と暗黙的の両方)を処理します。単に、Promiseチェーンの最後に。Promises will handle any exceptions(both explicit and implicit) in asynchronous code blocks that use then(). Just add.
より多くの例を表示
結果: 61 ,
時間: 0.0295
English
中文
عربى
Български
বাংলা
Český
Dansk
Deutsch
Ελληνικά
Español
Suomi
Français
עִברִית
हिंदी
Hrvatski
Magyar
Bahasa indonesia
Italiano
Қазақ
한국어
മലയാളം
मराठी
Bahasa malay
Nederlands
Norsk
Polski
Português
Română
Русский
Slovenský
Slovenski
Српски
Svenska
தமிழ்
తెలుగు
ไทย
Tagalog
Turkce
Українська
اردو
Tiếng việt