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.
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?
You need to replace then for when just when a class resolve to a promise. I don't see in you code any point to change, maybe the warning came from inside the api. Also happend to me to see warnings that came from inside the api and I can't resolve.
Like
view.then(function(){});
To
view.when(function(){});
When a method resolve to a promise you don't need to change.
Read more here: Making Better Promises | ArcGIS Blog
Here is a list of classes that have a then method: Overview | API Reference | ArcGIS API for JavaScript 4.6