dimanche 23 septembre 2018

make two or more objects and use them in rotation or random in node js

i have config.js file contain :

exports.smtp = {
    host: "smtp.mailtrap.io",
    port: "2525",
    auth: true,
    user: "3295b90cbc8837",
    pass: "x"
};

in another file i nget the smtp element like this :

var smtp = {
    host: config.smtp.host,
    port: config.smtp.port,
    secure: false
};

i need to create multiple smtp object and randomly choose which one to use . example :

exports.smtp = {
    host: "smtp.mailtrap.io",
    port: "2525",
    auth: true,
    user: "3295b90cbc8837",
    pass: "x"
};

exports.smtp = {
    host: "smtp.mailtrap.io",
    port: "2525",
    auth: true,
    user: "3295b90cbc8837",
    pass: "x"
};

between the two objects will be used in rotation .what ways might I do to make it like that?




Aucun commentaire:

Enregistrer un commentaire