File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ export default defineNuxtPlugin(async nuxtApp => {
1111 fetchAt : null ,
1212 async fetch ( ) {
1313 this . fetchAt = Date . now ( )
14- return dbUrl ? await fetch ( dbUrl ) . then ( res => res . json ( ) ) : [ ]
14+ try {
15+ return await fetch ( dbUrl ) . then ( res => res . json ( ) )
16+ } catch ( e ) {
17+ console . error ( e )
18+ return [ ]
19+ }
1520 }
1621 }
1722
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ export default defineNuxtPlugin(async nuxtApp => {
1212 fetchAt : null ,
1313 async fetch ( ) {
1414 this . fetchAt = Date . now ( )
15- return dbPath ? JSON . parse ( await readFile ( dbPath , 'utf8' ) ) : [ ]
15+ try {
16+ return JSON . parse ( await readFile ( dbPath , 'utf8' ) )
17+ } catch ( e ) {
18+ console . error ( e )
19+ return [ ]
20+ }
1621 }
1722 }
1823
You can’t perform that action at this time.
0 commit comments