Skip to content

Export the version #4064

@mastermatt

Description

@mastermatt

Is your feature request related to a problem? Please describe.

No. Feature request.
I'd like the version of the lib easily exposed to consumers.

Describe the solution you'd like

I'd like lib/axios.js to add the following:

var VERSION = require('./env/data').version;
// ...
axios.VERSION = VERSION;

Describe alternatives you've considered

Without this, I'm forced to dig around in node_modules trying to find axios/package.json or hard code the version in my code and hope it stays in sync.

Additional context

My primary use is for constructing a user-agent header, I'd prefer to include axios and it's version.
When writing apps that call between my services, I find debugging is easier when I can include a proper user agent header.

const defaultUA = `MyOrg MyService/${pkg.version} (Axios/${axios.VERSION} Node/${process.versions.node})`;

const instance = axios.create({
  // ...opts
  headers: { 'User-Agent': defaultUA }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions