خرید بک لینک

Vote count: -1

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 How do I retu the response from an asynchronous call? for help but it still don´t work.

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); // retu ID
  });
  retu streckenId;
};

streckenId = getStreckeID();
console.log("StreckeID:" + streckenId); //retu undefined

The last console.log still say that "streckenId" is undefined.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 12 خرداد 1395 ساعت: 3:01

صفحه بندی