DEV Community

loading...

Discussion on: Getting connected status on React Native

Collapse
taskonomyapp profile image
Taskonomy

let req = await fetch('google.com');
let hasConnection = req.status === 200;

giving me an error

Collapse
mutatedbread profile image
Ng Chen Hon Author

Hi,

Forgive me for this very late reply.

I am presuming you are getting the error when running it on iOS.

I had not taken into consideration that any network requests on iOS must be https or have the url placed into exception when I was writing this.

Please try with the below if you are still stuck on this.

let req = await fetch('https://www.google.com');
let hasConnection = req.status === 200;