react client real ip address
// this is the complete code, copy and use
import React from 'react';
const API = 'https://geoip-db.com/json';
const DEFAULT_QUERY = 'redux';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
hits: [],
isLoading: false,
};
this.setStateHandler = this.setStateHandler.bind(this);
}
setStateHandler() {
this.setState({ isLoading: true });
fetch(API + DEFAULT_QUERY)
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error('Something went wrong ...');
}
})
.then(data => this.setState({ hits: data.IPv4, isLoading: false }))
.catch(error => this.setState({ error, isLoading: false }));
}
render() {
return (
<div>
<button onClick = {this.setStateHandler}>Click</button>
<h2>{this.state.hits}</h2>
</div>
);
}
}
export default App;
Also in JavaScript:
- codeigniter csrf token ajax
- dom is loaded
- javascript code to loop through array
- JavaScript how do you create a screen pressable button in 10 lines?
- Setting “checked” for a checkbox with jQuery
- how to host a react website
- setting up a sprite sheet in js
- define an unsigned int js
- ajax .put
- video recorder using webrtc and javascript
- get epoch timestamp js
- discord js channel send
- add new key value pair to object javascript
- jquery watch checkbox change
- jquery clear html
- enable disable click on div jquery
- jquery get parameter from url
- how to download and install ssms in windows 10
- jquery create element
- get radio button value javascript
- for of js
- is json valid with single quotes
- android center text react native
- chrome add a javascript bookmark