AnsweredAssumed Answered

How to load a Layer to inspect its REST properties with Javascript?

Question asked by ryan.sutcliffe on Mar 29, 2019
Latest reply on Mar 30, 2019 by ryan.sutcliffe

I would like to fetch an ArcGIS featurelayer and get information on its properties and capabilities but I have no interest in rendering it in a map or a table. Is there a trick to load the featurelayer without inserting it in a map and view? Unless I do that I cannot figure out how to get its loaded property to be true.

var featureLayer = new FeatureLayer({
     url: url
});

featureLayer.when(function () {
// fires when layer is loaded:
     console.log(featureLayer.capabilities);
     //... do something with capabilities here...
});


// Do I really need to load the map and view modules?
var map = new Map({
     basemap: "oceans",
     layers: featureLayer
});
var view = new MapView({
     map: map,
     container: "viewDiv"
});

// after above is complete, layer will be loaded but is there
// a better way to avoid loading all this extra stuff?

I'm currently doing a straight fetch to get the layer's JSON information and parsing it manually but obviously would like to use the ArcGIS Javascript API to reduce the work and lines of code.

Outcomes