Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

robot mascot smiling

How To Get City and State Info from User’s IP Address using IP2Location

In this lesson, we'll learn how to get our user's city, region, and country location information using their IP address.

Published
Nov 03, 23
Duration
5m 21s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Today we’ll see how we can get our user’s city, state, and country location information using their IP address and a from a free library and database called IP2Location.

Since, when working locally in NodeJS/AdonisJS our IP address is going to be localhost (127.0.0.1), I’ve gone ahead and grabbed three different IP addresses from my VPN for us to use as examples.

  • Chicago, United States: 107.150.29.169

  • Frankfurt, Germany: 45.87.212.78

  • Stockholm, Sweden: 149.50.216.74

What we need to do now is get the location through some service, and then we can compare the location via the service by its accuracy for the VPN's name for the IP address listed above.

Adding IP2Location

Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.

robot comment bubble

Be the first to Comment!