ipify는 MIT 라이선스를 가진 오픈소스 애플리케이션이며 깃허브를 통해 코드를 받을 수 있습니다.
깃허브 주소 : https://github.com/rdegges/ipify-api
또한 많은 요청에도 제한이 없다는 장점이 있습니다.
예제는 아래와 같습니다.
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
async function getClientIP() {
try {
const response = await axios.get('https://api.ipify.org?format=json');
console.log(response);
} catch (error) {
console.error(error);
}
}
getClientIP();
</script>
출력
data: {ip: "198.16.76.28"}
'JavaScript' 카테고리의 다른 글
Math.random을 이용해 1~9 숫자 뽑기 (0) | 2022.04.11 |
---|---|
javascript 뒤로가기 막기 (0) | 2020.11.13 |
Node.js와 NPM 특정 버전 설치 (0) | 2020.05.08 |
JavaScript - 버튼 눌러 테이블 로우 추가 (0) | 2020.03.18 |