Last active
February 13, 2023 14:46
-
-
Save rodrigobdz/f9969f9e49cf24ef635db4ee90bf3459 to your computer and use it in GitHub Desktop.
Ping IP Address in React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetch('http://localhost') | |
| .then((response) => { | |
| console.log('response ', response) | |
| if (response.status === 200) { | |
| console.log('success') | |
| } else { | |
| console.warn('error') | |
| } | |
| }) | |
| .catch((error) => { | |
| console.error('network error: ' + error) | |
| }) |
Author
just a heads up. It doesn't work when you try to ping (fetch) an http URL from a https host.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@veera83372 Thanks for the heads-up