0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

reactのaxiosでリクエスト失敗時の例外処理をいれる

Posted at

catchで例外処理

        request
            .post("/getpodstatus", obj)
            // やりたい処理
            .then(request => {
                this.setState({
                    podstatus: request.data.items[0].status.phase
                });
                console.log(this.state.podstatus)
                }
            )

            // エラー時というかやりたい処理ができなかった場合の処理
            .catch(error => {
                this.setState({
                    podstatus: 'Stop'
                });
                console.log('POST失敗時の処理')
            })
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?