Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Show an Error when a POST or DELETE Fails in an Offline PWA

    reactReact
    16.6.3-16.8.6

    We're storing JSON data in the cache - but that only applies to HTTP GET requests - and not to POST or DELETE requests.

    We'll add a fetch event listener to the service worker, where we can intercept all fetch requests in our app. We'll forward them to the server - but if they fail, then we'll return an error back to the app.

    In the app, we can detect that error, and respond by showing an alert that the functionality isn't available in offline mode.