AnsweredAssumed Answered

Understanding Promise deprecation warnings in ArcGIS API for JavaScript?

Question asked by briencrean on Mar 5, 2018
Latest reply on Mar 6, 2018 by rodrigo.felga

I am trying to update legacy map code to the latest ArcGIS version of 4.6 and noticed this warning in the console when querying a feature layer.

[esri.core.Promise] DEPRECATED: then() -- use .when(callback, errback) instead

So I tried to change then to when, but got when is not a function errors. I also tried running the sample code from the site and got the same errors.

view.whenLayerView(featureLayer).then(function(lyrView) {
  lyrView.watch("updating", function(val) {
    if (!val) { // wait for the layer view to finish updating

    // query all the features available for drawing.
    lyrView.queryFeatures().then(function(results) {

      graphics = results;

      var fragment = document.createDocumentFragment();

      results.forEach(function(result, index) {
         var attributes = result.attributes;
         var name = attributes.ZIP + " (" +
         attributes.PO_NAME + ")"

         // Create a list zip codes in NY
         var li = document.createElement("li");
         li.classList.add("panel-result");
         li.tabIndex = 0;
         li.setAttribute("data-result-id", index);
         li.textContent = name;

         fragment.appendChild(li);
      });
      // Empty the current list
      listNode.innerHTML = "";
      listNode.appendChild(fragment);
      });
      }
   });
});

I also tried setting the "esri-promise-compatibility" flag to 1 but that didn't help. Can't see anything in the docs or community forums about this. Anyone come across this before?

Outcomes