[Javascript]promiseのcatch,then

promiseのcatch,then

<apex:page>
    <html>

        <head>

        </head>

        <body>

            <script type="text/javascript">

                Promise.resolve()
                .then(() => {
                    // Makes .then() return a rejected promise
                    throw new Error('Oh no!');
                })
                .catch(error => {
                    console.error('onRejected function called: ' + error.message);
                })
                .then(() => {
                    console.log("I am always called even if the prior then's promise rejects");
                });
            </script>

        </body>

    </html>
</apex:page>

結果

投稿者: kinkun

保有資格 Salesforce Certified Platform App Builder T Salesforce Certified Platform Developer I Salesforce Certified Platform Developer II Salesforce Certified Administrator

コメントを残す

メールアドレスが公開されることはありません。