javascript

Find IP Address using JavaScript

Here’s a simple program in JavaScript that can help you find the IP address of the device running the code:

This program uses the fetch API to make a GET request to the https://api.ipify.org?format=json endpoint, which returns the device’s IP address in JSON format. The response.json() method extracts the JSON data from the response, and the data.ip property is used to access the device’s IP address. Finally, the IP address is printed on the browser using document.getElementByID("response").innerHTML = data.ip.

I hope this program helps you understand how to print public IP Addresses using JavaScript Fetch API.

Related Posts

Leave a Reply