getItemResource

getItemResource

Function
getItemResource(itemIdstring, requestOptionsIGetItemResourceOptions): Promise<any>

Fetches an item resource and optionally parses it to the correct format.

Provides JSON parse error protection by sanitizing out any unescaped control characters before parsing that would otherwise cause an error to be thrown.

1
2
3
4
5
6
7
8
9
10
11
12
13
import { getItemResource } from "@esri/arcgis-rest-portal";

// Parses contents as blob by default
getItemResource("3ef", { fileName: "resource.jpg", ...})
 .then(resourceContents => {});

// Can override parse method
getItemResource("3ef", { fileName: "resource.json", readAs: 'json', ...})
 .then(resourceContents => {});

// Get the response object instead
getItemResource("3ef",{ rawResponse: true, fileName: "resource.json" })
 .then(response => {})
Parameters
ParameterTypeNotes
itemId
string
requestOptions
IGetItemResourceOptions
Returns 
Promise<any>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close