Comments (14)
Are you sure you check the correct parameter in the callback? The first is most likely the error (which will be undefined).
from is-online.
yep, I'm sure.
Here is my code:
isReachable('google.com:80', (err, reachable) => {
console.log(reachable);
});
or
isOnline(function(err, online) {
console.log(online);
});
from is-online.
And what does err return?
From the docs
Same as above except the callback doesn't have an error parameter.
Not sure if err is undefined or the first param actually is the result.
from is-online.
I've also tried the following while connected / disconnected:
isOnline(function(online) {
console.log(online);
});
Both results were false
from is-online.
BTW. I'm including it via import isOnline from 'is-online';
and compile it then with babel.
But that should not be the reason for this issue. I hope.
All the other ES6 stuff works well.
from is-online.
Neither is-online
nor is-reachable
are capable of returning undefined
to the callback. Try this in the REPL (the null true
are the callback args):
$ node
> require('is-reachable')('google.com', console.log)
undefined
> null true
from is-online.
@silverwind
GET file://google.com/favicon.ico?1457219323579 net::ERR_FILE_NOT_FOUND
maybe it's because of electron
?
from is-online.
You're getting the browser API: https://github.com/sindresorhus/is-reachable/blob/master/browser.js
As to why, I'm not sure, I thought electron scripts should get the node version?
from is-online.
Hey I ran into the same issue. It may be because there is no main
property set in the package.json
. Also if you're using browserify or webpack they will fallback to browser instead. Great little lib though.
Hope this helps.
from is-online.
It may be because there is no main property set in the package.json.
Proof? Electron handles no "main" just fine, which is optional if you have an index.js
file.
from is-online.
@sindresorhus I experienced a similar issue and at the time was investigating that avenue. It was a maybe rather than a definite.
The actual issue is that the documentation is wrong on the signature of the function.
The first item is the online status and not an error. Thats why they're getting undefined.
isOnline((online) => {
$scope.isOnline = online;
});
should work as expected.
from is-online.
I'd say the documentation is right. Both is-online
and is-reachable
have:
Browser API
Same as above except the callback doesn't have an error parameter.
from is-online.
The issue here is still, that electron should never get browser.js
in first place. Maybe someone affected can test if adding main
resolves this.
from is-online.
in fact electron runs two processes
main
process (node server)renderer
(chromium browser / client)
so (it is how it should be) if you run it from the renderer
it's the browser api.
from is-online.
Related Issues (20)
- Is it possible to pass URL in config? HOT 8
- Unable to install, 404 Not Found: @szmarczak/http-timer@^1.1.2 HOT 1
- use the is-online prompt requires a loader,but i don't know how to install the loader HOT 1
- Test URL `https://ipv4.icanhazip.com/` is not working. HOT 1
- Problem using is-online behind a proxy HOT 1
- [package.json tags] - consider adding "no" to the tags list
- Connection Refused HOT 1
- Apple captive portal check HOT 2
- Why do you use http protocol for apple's captive website? HOT 4
- Check if network adapter exists in Node.js before trying to connect HOT 1
- isOnline().then giving error that it is not a function after new update 8.5.0 HOT 1
- Client-side scalability across hundreds of devices on same IP address HOT 1
- Critical dependency: the request of a dependency is an expression HOT 1
- How can I emulate the Offline mode? HOT 1
- ~20 seconds just for true or false? HOT 1
- Browser support
- Error in electron HOT 1
- You may need an appropriate loader to handle this file type. HOT 1
- Error: getsockname EBADF HOT 1
- Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules\is-online\index.js not supported. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from is-online.