Sending a fetch request while connected to an iOT device without internet

302 Views Asked by At

I'm developing an iOS app using Ionic (JavaScript Framework) and I'm connecting to an Iot device and sending a fetch request to it.

If my phone doesn't have a cellular connection, the fetch fails.

This is the process:

  1. Turn on Iot device

  2. Use app to connect to device access point

  3. Send fetch request to device

     try {
       const response = await fetch('http://192.168.1.1/');
       // handle response
     } catch(err) {
       console.log(err);
       // handle error
    }
    
  4. Fetch fails

Is there a way for the fetch to work when connected to an access point without internet? Are there any other libraries that might help me achieve this?

0

There are 0 best solutions below