Solved! Go to Solution.
var legendImageRequest = esriRequest({ url : "https://www.server.com/arcgis2/rest/services/test/test/MapServer/legend", content : {f : "json"}, handleAs : "json", }); legendImageRequest.then(function(response) { console.log(response.layers[0].legend[0]); });