|
72 | 72 | async getChannelTitleAndAvatar() { |
73 | 73 | this.isSending = true; |
74 | 74 |
|
75 | | - const response = await getChannelTitleAndAvatar(this.channelId, this.apiKey); |
76 | | -
|
77 | | - this.channelAvatar = response["items"][0].snippet.thumbnails.default.url; |
78 | | - this.channelTitle = response["items"][0].snippet.localized.title; |
79 | | -
|
80 | | - this.isSending = false; |
| 75 | + try { |
| 76 | + const response = await getChannelTitleAndAvatar(this.channelId, this.apiKey); |
| 77 | +
|
| 78 | + this.channelAvatar = response["items"][0].snippet.thumbnails.default.url; |
| 79 | + this.channelTitle = response["items"][0].snippet.localized.title; |
| 80 | + } |
| 81 | + catch(error) { |
| 82 | + console.log(error); |
| 83 | + } |
| 84 | + finally { |
| 85 | + this.isSending = false; |
| 86 | + } |
81 | 87 | }, |
82 | 88 | async getSubscribersCount() { |
83 | 89 | this.isSending = true; |
84 | 90 |
|
85 | | - const response = await getSubscribersCount(this.channelId, this.apiKey); |
86 | | -
|
87 | | - this.subscribersCount = response["items"][0].statistics.subscriberCount; |
88 | | - this.totalVideosCount = response["items"][0].statistics.videoCount; |
89 | | -
|
90 | | - this.isSending = false; |
| 91 | + try { |
| 92 | + const response = await getSubscribersCount(this.channelId, this.apiKey); |
| 93 | +
|
| 94 | + this.subscribersCount = response["items"][0].statistics.subscriberCount; |
| 95 | + this.totalVideosCount = response["items"][0].statistics.videoCount; |
| 96 | + } |
| 97 | + catch(error) { |
| 98 | + console.log(error); |
| 99 | + } |
| 100 | + finally { |
| 101 | + this.isSending = false; |
| 102 | + } |
91 | 103 | }, |
92 | 104 | async getVideos() { |
93 | 105 | this.isSending = true; |
94 | 106 |
|
95 | | - const response = await getVideos(this.channelId, this.apiKey, this.resultsPerRequest); |
96 | | -
|
97 | | - this.videos = response.items; |
98 | | - this.nextPageToken = response.nextPageToken; |
99 | | -
|
100 | | - this.isSending = false; |
| 107 | + try { |
| 108 | + const response = await getVideos(this.channelId, this.apiKey, this.resultsPerRequest); |
| 109 | +
|
| 110 | + this.videos = response.items; |
| 111 | + this.nextPageToken = response.nextPageToken; |
| 112 | + } |
| 113 | + catch(error) { |
| 114 | + console.log(error); |
| 115 | + } |
| 116 | + finally { |
| 117 | + this.isSending = false; |
| 118 | + } |
101 | 119 | }, |
102 | 120 | async loadMore() { |
103 | 121 | this.isSending = true; |
104 | 122 |
|
105 | | - const response = await loadMoreVideos(this.channelId, this.apiKey, this.resultsPerRequest, this.nextPageToken); |
106 | | -
|
107 | | - this.videos = [...this.videos, ...response.items]; |
108 | | - this.nextPageToken = response.nextPageToken; |
109 | | -
|
110 | | - this.isSending = false; |
| 123 | + try { |
| 124 | + const response = await loadMoreVideos(this.channelId, this.apiKey, this.resultsPerRequest, this.nextPageToken); |
| 125 | +
|
| 126 | + this.videos = [...this.videos, ...response.items]; |
| 127 | + this.nextPageToken = response.nextPageToken; |
| 128 | + } |
| 129 | + catch(error) { |
| 130 | + console.log(error); |
| 131 | + } |
| 132 | + finally { |
| 133 | + this.isSending = false; |
| 134 | + } |
111 | 135 | }, |
112 | 136 | }, |
113 | 137 | mounted() { |
|
0 commit comments