net
object exposes methods for retrieving data from the Web and performing arbitrary HTTP requests.node-fetch
polyfill of the Fetch API.Promise<String>
net.getText(String url, [Object options])
Promise
.url |
The URL to query.
|
options |
Custom options passed to
fetch() . |
const trulyRandomNumber = await net.getText('https://www.random.org/cgi-bin/randbyte?nbytes=1&format=d');
cli.tell(trulyRandomNumber);
Promise<Any>
net.getJSON(String url, [Object options])
Promise
.url |
The URL to query.
|
options |
Custom options passed to
fetch() . |
const tasklemonNpmDetails = await net.getJSON('https://registry.npmjs.org/tasklemon');
const lastReleaseDate = tasklemonNpmDetails.time.modified;
cli.tell('Last Tasklemon release was ' + format.date.relative(lastReleaseDate) + '.');
Promise<JSDOM>
net.getDOM(String url, [Object options])
JSDOM
object, as a Promise
.url |
The URL to query.
|
options |
Custom options passed to
fetch() . |
const weekendDOM = await net.getDOM('http://isitweekendyet.com');
const weekendEstimation = weekendDOM.querySelector('div').textContent.trim();
cli.tell('Is it the weekend yet? ' + weekendEstimation);
Promise<Response>
net.fetch(String|Request input, [Object init])
input |
The URL to query or request to perform.
|
init |
Fetch options.
|
const response = await net.fetch(await cli.ask('URL to check?'));
cli.tell('URL is ' + response.ok ? 'OK' : 'not OK');