import { request , IRequestOptions } from "@esri/arcgis-rest-request" ; import { getHubApiUrl , IHubRequestOptions } from "@esri/hub-common" ; import { _getDomainServiceUrl } from "@esri/hub-common" ; param siteId param requestOptions returns export function getDomains ( siteId , requestOptions ? ) { const url = _getDomainServiceUrl ( getHubApiUrl ( requestOptions ) ) ; const options = { params : { siteId } , httpMethod : "GET" , ... requestOptions , } ; return request ( url , options ) ; } param siteId param requestOptions returns export function getDomain ( siteId , requestOptions ? ) { return getDomains ( siteId , requestOptions ) . then ( ( response ) => { if ( response . length > 1 ) { const customEntry = response . reduce ( ( acc , entry ) => { if ( ! entry . hostname . includes ( "arcgis.com" ) ) { acc = entry ; } return acc ; } , null ) ; if ( customEntry ) { return customEntry . hostname ; } else { return response [ 0 ] . hostname ; } } else { return response [ 0 ] . hostname ; } } ) ; }