Skip to content

Commit bd424d0

Browse files
committed
Add fallback for failed API call
1 parent 48bbcb6 commit bd424d0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

serviceworker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ workbox.routing.registerRoute(
4242
]
4343
})
4444
);
45+
46+
workbox.routing.setCatchHandler(({event}) => {
47+
// respond with "app offline" message when API cannot be reached
48+
if (apiURL.test(event.request.url)) return caches.match("/offline/decode.json");
49+
});

0 commit comments

Comments
 (0)