@@ -73,7 +73,8 @@ import { getDecryptedText, getDepryctionKey } from '~/helpers/decrypt'
7373import { v2DiffData } from ' ~/helpers/types'
7474import {
7575 E2E_DATA_DECRYPTING_INFO ,
76- E2E_DATA_ERROR ,
76+ E2E_DATA_DECRYPTION_ERROR ,
77+ E2E_DATA_FETCH_ERROR ,
7778 E2E_DATA_FINALIZING_INFO ,
7879 E2E_DATA_LOADING_INFO ,
7980 E2E_DATA_NO_LONGER_AVAILABLE_ERROR ,
@@ -134,12 +135,20 @@ export default Vue.extend({
134135 },
135136 async getE2EData() {
136137 this .e2eDataStatusText = E2E_DATA_LOADING_INFO
138+ const url = new URL (window .location .href )
139+ const id = url .searchParams .get (' id' )
140+ const key = url .hash .replace (/ ^ #/ , ' ' )
141+ let response = null ;
142+ let data = null
143+ try {
144+ response = await fetch (` /api/getLink?id=${id } ` )
145+ data = await response .json ()
146+ } catch (error ) {
147+ console .error (error )
148+ this .e2eDataStatusText = E2E_DATA_FETCH_ERROR
149+ return null
150+ }
137151 try {
138- const url = new URL (window .location .href )
139- const id = url .searchParams .get (' id' )
140- const key = url .hash .replace (/ ^ #/ , ' ' )
141- const response = await fetch (` /api/getLink?id=${id } ` )
142- const data = await response .json ()
143152 if (data .length === 0 ) {
144153 this .e2eDataStatusText = E2E_DATA_NO_LONGER_AVAILABLE_ERROR
145154 return null
@@ -157,7 +166,7 @@ export default Vue.extend({
157166 return decryptedData
158167 } catch (error ) {
159168 console .error (error )
160- this .e2eDataStatusText = E2E_DATA_ERROR
169+ this .e2eDataStatusText = E2E_DATA_DECRYPTION_ERROR
161170 return null
162171 }
163172 },
0 commit comments