Skip to content

DevExploris/IPTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - IP address tracker solution

This is a solution to the IP address tracker challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

Links

My process

Built with

What I learned

It is first time for me to use 3 API on same time with fetch and async / await properties.

async function FetchApi(url) {
  if(url !== apiOnLoad) {
    url = 'https://geo.ipify.org/api/v2/country,city?apiKey=at_krAgkVfXkGjs1FhIXlhUjKCk3qexX&ipAddress=' + inputIp.value;
  }
  let api = await fetch(url).then((response) => {
    if (response.ok) {
      return response.json();
    } else {
      throw new Error('IP Address unknown');
    }
  }).catch(error => console.log(error));
  if (api === undefined) {
    api = await fetch('https://geo.ipify.org/api/v2/country,city?apiKey=at_krAgkVfXkGjs1FhIXlhUjKCk3qexX&domain=' + inputIp.value).then((response) => {
      if (response.ok) {
        return response.json();
      } else {
        throw new Error('Domain unknown');
      }
    }).catch(error => console.log(error));
    if(api === undefined) {
      return null;
    }
  }
  return api;
}

Continued development

I am impatient to try again use leafletJS and Mapbox for another projects ! I will continue to use async / await since I understand to use with this project !

Author

Acknowledgments

I made this project alone.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published