質問編集履歴

1

typeof を使った場合のエラーメッセージを記入

2018/03/23 10:59

投稿

violineer
violineer

スコア72

test CHANGED
File without changes
test CHANGED
@@ -25,3 +25,33 @@
25
25
  ```
26
26
 
27
27
  でhogeにerrorが入っていることから条件分岐させて処理したいです。
28
+
29
+
30
+
31
+ typeofを使用した場合
32
+
33
+ 下記のような状態になってしまいます
34
+
35
+ ```エラー
36
+
37
+ Unhandled Rejection (TypeError): Cannot read property 'status' of undefined
38
+
39
+ Show._callee3$
40
+
41
+ src/Courses.js:227
42
+
43
+ 224 | const course = await this.props.api.showCourse(
44
+
45
+ 225 | this.props.match.params.courseId
46
+
47
+ 226 | );
48
+
49
+ > 227 | if (typeof course.response.status !=="undefined") {
50
+
51
+ 228 | this.setState({ isValidUrl: false });
52
+
53
+ 229 | return;
54
+
55
+ 230 | }
56
+
57
+ ```