-
Notifications
You must be signed in to change notification settings - Fork 4
Get IP info #3
Copy link
Copy link
Open
Description
I'd like to add IP / localization information. Here I've found this nice little piece of code:
fetch('https://extreme-ip-lookup.com/json/')
.then( res => res.json())
.then(response => {
console.log("Country: ", response.country);
})
.catch((data, status) => {
console.log('Request failed');
})That fetches a json object containing some useful information. However, I'd like to put it in a function so that it returns the whole object, or an object {status: "failure"} if it fails. But I don't know how to extract the whole response object from the .then promise 😅 @penguimelia any idea?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels