title: Wait for the response of the Api - Angular js 2
body: <p>I would like to put a token in a cookie the only problem and that the cookie is created before getting the response of the API, how is it that I can do to wait for a response and then create the cookie?</p>
  
  <p>My Code</p>
  
  <pre><code>getlogin()
  {
  this._symfonyservice.login(this.user,this.pass).subscribe(//call the post
              data =&gt; this.results = data, // put the data returned from the server in our variable
              error =&gt; console.log("Error HTTP Post Service"), // in case of failure show this message
              () =&gt; console.log(this.results['token'])//run this code in all cases
          );
  if(this.results['token']!="")
  {
      let token = this.results['token'];
      this.deleteCookie("Cookieteste");
      this.setCookie("Cookieteste",token, 1);
  }
     }
  </code></pre>