Added ip json stuff

This commit is contained in:
z0ccc 2021-06-06 02:11:09 -04:00
parent ecd633f108
commit dfd8398285

View file

@ -4,6 +4,17 @@ import './App.css';
const App = () => { const App = () => {
useEffect(() => { useEffect(() => {
// Make the request
fetch('http://ip-api.com/json')
.then((response) => response.json())
// Do something with the JSON data
.then((data) => {
console.log(data.query);
document.getElementById(
'ipAddress'
).innerHTML += `IP address: ${data.query}`;
});
document.getElementById( document.getElementById(
'screenSize' 'screenSize'
).innerHTML += `Screen resolution: ${window.screen.width}x${window.screen.height}`; ).innerHTML += `Screen resolution: ${window.screen.width}x${window.screen.height}`;
@ -28,6 +39,8 @@ const App = () => {
return ( return (
<div className="App"> <div className="App">
<div className="title">Connection</div>
<div className="item" id="ipAddress" />
<div className="title">Hardware</div> <div className="title">Hardware</div>
<div className="item" id="screenSize" /> <div className="item" id="screenSize" />
<div className="item" id="batteryLevel" /> <div className="item" id="batteryLevel" />