'Dynamic http transport options

I am using winston js with http transport. I would like to use an auth property but with different bearer tokens. So for initial load I'd like to set a bearer token taken from query params but after some time I would like to override that value to other token. How can I achieve that in Winston?

More details:

const startupHttpConfiguration = {
    host: HOST,
    port: PORT,
    path: "/log_endpoint",
    auth: {
        bearer: token_from_query_params
    },
    batch: true,
    batchCount: 10,
    batchInterval: 3000,
    level: "debug",
};

Later I'd like to have that configuration:

const httpConfiguration = {
    return {
        host: HOST,
        port: PORT,
        path: "/log_endpoint",
        auth: {
            bearer: different_token
        },
        batch: true,
        batchCount: 10,
        batchInterval: 3000,
        level: "debug",
    };
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source