I noticed that since I updated on Aug 10th my openweathermap.ssjs is not pulling a json file but there is no log as to why.
I tried jsexec openweathermap.js but nothing is displayed. Any ideas?
@VIA: ECBBS
@MSGID: <5D557010.24065.sync_sys@bbs.electronicchicken.com>
@REPLY: <5D556A5A.1188.dove-syncops@alleycat.synchro.net>
@TZ: c12c
Re: Openweathermap
By: Mortifis to All on Thu Aug 15 2019 11:21:14
I noticed that since I updated on Aug 10th my openweathermap.ssjs is not pulling a json file but there is no log as to why.
For whatever reason I wrapped the entire working part of that script in a try ... catch
block and didn't bother to log the error.
You could at a log statement to line 21 in place of the "// meh" comment.
Or you could just
add "writeln(err)", and if there's an exception it'll be written into your sidebar. Not
pretty, but for momentary debugging it'll do.
If there's no debug output from that, then the next most likely things are:
- Failure in geoip lookup (also a silent error)
- Empty response from openweathermap
I tried jsexec openweathermap.js but nothing is displayed. Any ideas?
That's a library script, so it doesn't do anything on its own.
You could make a test script such as:
require('openweathermap.js', 'OpenWeatherMap');
const owm = new OpenWeatherMap();
const res = owm.call_api('weather', {
units: 'metric',
mode: 'html',
q: 'Halifax,ca'
}, true);
writeln(JSON.stringify(res));
This should dump an object to the console when run from jsexec, or produce an error.
forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, butwhere
would I look to 'adjust' the output, or, eve, any ideas why calling 'forecast' render a blank page?
@VIA: ECBBS
@MSGID: <5D560125.24070.sync_sys@bbs.electronicchicken.com>
@REPLY: <5D55EBDA.1193.dove-syncops@alleycat.synchro.net>
@TZ: c12c
Re: Re: Openweathermap
By: Mortifis to echicken on Thu Aug 15 2019 20:33:46
forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but where would I look to 'adjust' the output, or, even, any ideas why calling 'forecast' renders a blank page?
What's the value of 'wq' in this instance?
@VIA: ECBBS
@MSGID: <5D560125.24070.sync_sys@bbs.electronicchicken.com>
@REPLY: <5D55EBDA.1193.dove-syncops@alleycat.synchro.net>
@TZ: c12c
Re: Re: Openweathermap
By: Mortifis to echicken on Thu Aug 15 2019 20:33:46
forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but where would I look to 'adjust' the output, or, eve, any ideas why calling 'forecast' render a blank page?
What's the value of 'wq' in this instance?
Ok, I see what's going on, the 5 day forecast is only mode json or xml,so
omitting the mode I do get a response, just no pretty parsed contents LOL
@VIA: ECBBSxml,
@MSGID: <5D56C388.24076.sync_sys@bbs.electronicchicken.com>
@REPLY: <5D566879.1198.dove-syncops@alleycat.synchro.net>
@TZ: c12c
Re: Re: Openweathermap
By: Mortifis to echicken on Fri Aug 16 2019 05:25:29
Ok, I see what's going on, the 5 day forecast is only mode json or
so omitting the mode I do get a response, just no pretty parsed contents LOL
That makes sense, then.
So what you would want instead is something like:
require('openweathermap.js', 'OpenWeatherMap');
const owm = new OpenWeatherMap();
const wq = { units: 'metric', mode: 'json', q: 'Halifax,ca' };
const fc = owm.call_api('forecast', wq);
writeln(fc.list[0]); // See what an 'fc.list' element looks like
fc.list.forEach(function (e) {
writeln(new Date(e.dt).toLocaleString());
writeln(e.main.temp + ',' + e.main.temp_min + ',' + e.main.temp_max);
writeln(e.weather[0].main + ', ' + e.weather[0].description);
writeln(e.clouds.all + '% cloudy');
});
The above should work properly with jsexec. Easily adapted to run on your webserver, using geoip and wrapping stuff in HTML (I would suggest an XJS file instead of SSJS).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 235:51:31 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,769 |