I'm trying to ping up a few IP address by type script React. I found the code - https://github.com/alfg/ping.js/tree/master With this code the ping to the web sites works but when replacing the web site domain with my IP addresses the error on the console shows on display.
My Code:
import React from 'react';
import './ftp.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import Button from 'react-bootstrap/Button';
import Ping from '../node_modules/ping.js';
class Ftp extends React.Component {
constructor() {
super();
this.p = new Ping();
this.state = {
server36: 0,
};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.p.ping("http://apple.com", (err, data) => {
if (err) {
console.log("error loading resource", err);
}
this.setState({ server36: data });
});
}
render() {
return (
<div className="grid-container">
<div className="grid-item">
<Button variant="success" onClick={this.handleClick} className="Button">PING</Button>
<ul>
<li>apple.com - <span>{this.state.server36} ms</span></li>
</ul>
</div>
</div>
)
}
}
export default Ftp;
Is there a way to get ping to IP addresses with ReactJS ?