Skip to content

v0.5.0

Compare
Choose a tag to compare
@lucaswerkmeister lucaswerkmeister released this 04 Dec 20:38
· 203 commits to main since this release

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 include warn, which must be a function. The fetch.js and axios.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 import browser.js or node.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.