title: how to run functions one after the other while using redis?
body: <p>I have the following code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr1 =['1','2','3'];
  client.sadd("arr1",arr1);
  var arr2=['2','4','6'];
  var arr3 =['3','6','9'];
  client.sadd("arr2",arr2);
  client.sadd("arr3",arr3);
  client.sadd("arraylist",'arr1','arr2','arr3');
  function getValue(value){
   client.smembers("arraylist",function(err,data){
    if(err) console.log(err);
    else {
     console.log(data);
    data.forEach(function(res){
     console.log(res);
     client.smembers(res,function(err,data){
      if(err) console.log(err);
      else data.forEach(function(val){
       if(val==value){
        client.sadd("validarr",res);
           console.log("stored!")
       }
      })
     })
     
    
    })
    
    }
   })
  }
    function randarr(){
   client.srandmember("validarr",function(err,response){
    if(err) console.log(err);
    else console.log(response);
   })
  };
  
  
  promise.resolve(getValue(2)).then(function()
  {
   console.log("hey");
   promise.resolve(randarr()).then(function(){
    console.log("done")
   },function(err){console.log("error")})
  })</code></pre>
  </div>
  </div>
  </p>
  
  <p>I want to execute the function randarr() after the complete execution of the function getValue , because i want to use the saved set validarr in the next function randarr().</p>
  
  <p>i tried using async.series. It turns out that both the functions were running simultaneously and printing the output in order.</p>
  
  <p>So by using promise.then i am facing the same error
  The output for the code using promises :</p>
  
  <pre><code>hey 
  done
  connected
  [ 'arr2','arr3',arr1']
  arr2
  arr3
  arr1
  null
  stored!
  stored!
  </code></pre>
  
  <p>The functions are not getting executed in order.What should i use inorder to run the functions one after another.</p>
  
  <p>Can someone help me with this code?</p>