axios random url picking

Tags: , ,

I just wonder how to pick random URLs to performed an axios post request.

I have three servers I want to pick randomly from

let one = ""
let two = ""
let three = ""

currently is using only one:

let req = await"", body, {

I just want to choose random port from


Example of a solution via an array

// Defining an array
var arr = ['adress1', 'adress2', 'adress3'];

// Getting a random array key
var rand = Math.floor(Math.random() * arr.length);

alert(arr[rand]); // "adress2" for example

Source: stackoverflow