Menu Get IP
 

Get IP

This page has the code to retrieve a stored IP from a file on the server using Fetch API and to check the current IP address with a call to the ipify API.

Stored IP: Stored IP address

Current IP: Current IP address

The console will contain the results of the API calls.

The Fetch API has to be run from the server, it will generate errors in console. These will be failure to fetch.

The next step is to hide the conditional link if the 2 IPs are the same. I have the code working as the response to a button click but I want it to run when the page loads.

I also need a routine to update the stored ip if it should change or am accessing from a different location.

Top

The Code

The two API calls:

What I am trying to do here

This page is working pretty well. I now have the two API calls working in pretty much the way that I want. I admit that it was quite a steep learning curve and there are still many things to work out.

Having said that, I have gained some knowledge to enable me to improve the site overall. The ability to test whether I am the one that is accessing my pages is one that I have been juggling for a while. There are a number of reasons for this not least important that it was an accademic challange. Being able to post links that only I can follow is a big one for me. Not only does it overcome the "look-up service" aspect it also will allow me to customize what I see and others see on the website.

There is no reason why I can't make all the outbound hyperlinks just visible to a visitor from my current IP. However, a single research link would probably be sufficient.

Links

Link to PDF Disabled

If you require a copy please email tempusfugit.me.uk

Top

References - a note on these

Site design by Tempusfugit Web Design -