ip-api-lookup-mark-uae
v1.0.4
Published
Using your package:
Downloads
442
Readme
ip-api-lookup-mark-uae
Using your package:
Import and use getGeoLocation with user input : ipapi.com provider
Bash
npm install ip-api-lookup-mark-uae
Use code with caution.
Import and use getGeoLocation with user input:
JavaScript
CODE
const { getGeoLocation } = require('ip-api-lookup-mark-uae');
const userIp = prompt("Enter an IP address:"); const userApiKey = prompt("Enter your API key (from https://ipstack.com/signup):");
getGeoLocation(userIp, userApiKey) .then(data => console.log(data)) .catch(error => console.error(error));
Use code with caution.
Explanation:
We use prompt to get user input for IP and API key.
Remember to replace "YOUR_API_KEY" with your actual API key in the example usage.
This approach creates a reusable package for geolocation lookup, accepting user input for the IP address and API key.
Additional notes:
Consider adding unit tests to ensure your code's functionality.
You can improve user experience by handling invalid input or API errors gracefully.
Explore options for environment variables instead of prompting for the API key in the published package.