LIst all ArcGIS Server Feature Services

Esri ArcGIS JavaScript API 3.24

by Alex Azuero

HTML

<link rel="stylesheet" href="https://js.arcgis.com/3.24/esri/css/esri.css">
<script src="https://js.arcgis.com/3.24/init.js"></script>
<script type="text/javascript">
  var dojoConfig = {
    async: true
  };

</script>
<div id="wrapper">
</div>

CSS

body,
html {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

#map {
  height: 100%;
  width: 100%;
  margin: 0px;
}

JavaScript

require([
  'esri/request',
  'dojo/dom'
], function(
  esriRequest,
  dom
) {

  var baseUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/";

  esriRequest({
    url: baseUrl,
    content: {
      "f": "json"
    },
    callbackParamName: "callback"
  }).then(function(response) {
    
    // derived from Kelly Hutchins at https://community.esri.com/thread/166512
    var serviceUrls = response.services.map(function(service) {
    	return "<a target='_blank' href='" + baseUrl + "/services/" + service.name + "/" + service.type + "'>" + service.name + "</a><br>";
    });
    dom.byId("wrapper").innerHTML = serviceUrls.join("");

  });
});