v0.5.0
Abbreviate api.php
URL as domain, warn on requests without user agent.
-
BREAKING CHANGE (internal): The
Session
constructor now requires the default request options to includewarn
, which must be a function. Thefetch.js
andaxios.js
backends already add a default for this option, so this is only relevant for you if you wrote a custom network implementation; if you just importbrowser.js
ornode.js
, it doesn’t matter. -
The first constructor argument can now be a domain name instead of a full
api.php
URL, e.g.en.wikipedia.org
instead of
https://en.wikipedia.org/w/api.php
. -
Requests that do not specify a user agent will now trigger a warning, limited to once per session. If you see this warning, you should add a
user agent to your requests – see the User-Agent policy. Usually you would add it to the default options at construction time:const session = new Session( 'en.wikipedia.org', { formatversion: 2, // other default params... }, { userAgent: 'my-cool-tool', // other default options... } );
But it can also be specified for an individual request:
const response = await session.request( { action: 'query', // other params... }, { userAgent: 'my-cool-tool', // other options... } );
Recall that the default warning handler is
console.warn
in the browser, and also in Node.js if NODE_ENV = “development” is set, but otherwise the Node.js backend ignores warnings.