I need to access the username promise from the layers-add-result event, but it is ignored. I think I can illustrate it best in code.
function init() {
require([], function() {
On(map, 'load', mapLoaded);
function mapLoaded() {
getUserName().then(function (res) {
// This part is executed
});
}
On(map, 'layers-add-result', initMapLayerData);
function initMapLayerData(evt) {
// This part is executed
getUserName().then(function (res) {
// This part is NOT executed
});
}
});
}
function getUserName() {
return new Promise(function (resolve, reject) {
require(["esri/IdentityManager"], function (esriId) {
esriId.on("credential-create", function (e) {
var userName = e.credential.userId;
resolve(userName);
});
});
});
}
What am I doing wrong? How do I access the user id from the layers-add-result event?
Thanks
Naci,
I think it is the fact that you are using the credential-create event to listen for and this is not being fired when the layer is added. You can use
To get the apps userId.