title: Angularjs $http post promise
body: <p>I try to use the promise respond from a $http.post, to get back the new ID of the record as integer and use it for the next $http.post. I used <a href="https://stackoverflow.com/q/14220321/616717">How do I return the response from an asynchronous call?</a> for help but it still don´t work. </p>
  
  <pre><code>var streckenId;
  var trackpunktId;
  
  var getStreckeID = function () {
    $http.post(dbStrecke, {"ort": location, "distanz": km}).then(function (response) {
      streckenId = response.data;
      console.log("ID (then): " + streckenId); // return ID
    });
    return streckenId;
  };
  
  streckenId = getStreckeID();
  console.log("StreckeID:" + streckenId); //return undefined
  </code></pre>
  
  <p>The last console.log still say that "streckenId" is undefined.</p>