2

Why do I get error:

"The "url" argument must be of type string. Received type undefined"

when I run this code:
P.S. I also tried to pass in variable with this URL, but the result was the same.

var axios = require('axios')();

module.exports = {
    async getJSONAsync(){


        let json = await axios.get('https://tutorialzine.com/misc/files/example.json');

        return json;
    }
};

NOTE: I use this function in another async function with await keyword. Like :

async begin() {

        try {
            let setup = new SetUp(this.bot);
            await testapi.getJSONAsync().then(function (json) {
                console.log(json)
            });
            let settings = await setup.prepareTest();
            let session = await settings.driver.getSession();
            logger.logDebug('Launching ' + this.test.name);

            return settings;
        }

        catch (e) {

            logger.logErr('Error when create settings for ' + this.test.name);
            throw e;

        }

    }
LittleJohnny
  • 105
  • 2
  • 13

1 Answers1

2
  require('axios')()

That will import axios and directly calls it with the no argument at all, therefore it will complain as the url it expects is not passed. Maybe just dont call it here?

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151