Skip to content

Get IP info #3

@DominiqueMakowski

Description

@DominiqueMakowski

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions