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.

Use dark colors for code blocksCopy
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.