Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

conditional statement for node on internet and node local server


if(os.hostname().indexOf("local") > -1){
  const DATABASE = 'local_database';
  var options = {
    host: 'localhost',
    port: 8889,
    user: 'root',
    password: 'root',
    database: DATABASE
  };
}else{
   const DATABASE = 'online_database';
  var options = {
    host: 'localhost',
    port: 3306,
    user: 'online_username',
    password: 'online_password',
    database: DATABASE
  };
}
 
PREVIOUS NEXT
Tagged: #conditional #statement #node #internet #node #local #server
ADD COMMENT
Topic
Name
9+8 =