How to use the @esri/arcgis-rest-portal.getItem function in @esri/arcgis-rest-portal

To help you get started, we’ve selected a few @esri/arcgis-rest-portal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / arcgis-rest-js / demos / ago-node-cli / lib / item-export-command.js View on Github external
execute: function (id, fileName) {
    console.info(`Exporting item ${id} to file ${fileName}`);
    // construct the search call..
    let model = {};
    return getItem(id)
    .then((item) => {
      model.item = item;
      if (this.shouldFetchData(item.type)){
        console.info(`...Fetching ./data for item of type ${item.type}`);
        return getItemData(id);
      } else {
        console.info(`...Items of type ${item.type} do not have json ./data - skipping`);
        return Promise.resolve();
      }
    })
    .then((maybeData) => {
      if (maybeData) {
        model.data = maybeData;
      }
      // now write out the file...
      jsonfile.writeFileSync(fileName, model,  {spaces: 2});
github Esri / arcgis-rest-js / demos / webmap-checker-sapper / src / routes / webmaps / [webmapId].html View on Github external
// redirect to the homepage unless the user is signed in
      if (!session) {
        this.redirect(302, "/");
        return;
      }

      const { webmapId } = params;

      // if we are on the server we won't have an actuall UserSession just a
      // JSON representation of one. So we need to hydrate a UserSession.
      const userSession = process.browser ? session : new UserSession(session);

      // next we can request both the webmap item and the webmap data (the JSON)
      // and process the data to get a list of layers.
      return Promise.all([
        getItem(webmapId, {
          authentication: userSession
        }).catch(error => {
          return retryWithNewSession(error, this.fetch);
        }),
        getItemData(webmapId, {
          authentication: userSession
        }).catch(error => {
          return retryWithNewSession(error, this.fetch);
        })
      ]).then(([item, webmap]) => {
        const layers = webmap.operationalLayers
          .concat(webmap.baseMap.baseMapLayers)
          .map(layer => {
            return {
              title: layer.title || layer.id,
              url: layer.url,
github Esri / arcgis-rest-js / demos / webmap-checker-sapper / src / components / LayerStatus.html View on Github external
loadItemId() {
        const { itemId, url } = this.get();
        const { session } = this.store.get();

        if (itemId) {
          getItem(itemId, {
            authentication: session
          })
            .catch(error => {
              return retryWithNewSession(error, fetch);
            })
            .then(item => {
              this.set({ item, url: url || item.url });
            });
        }
      },
github Esri / solution.js / packages / common / src / restHelpersGet.ts View on Github external
export function getItem(
  id: string,
  authentication: interfaces.UserSession
): Promise {
  const requestOptions = {
    authentication: authentication
  };
  return portal.getItem(id, requestOptions);
}
github Esri / solution.js / packages / common / src / restHelpersGet.ts View on Github external
export function getItemBase(
  itemId: string,
  authentication: interfaces.UserSession
): Promise {
  const itemParam: request.IRequestOptions = {
    authentication: authentication
  };
  return portal.getItem(itemId, itemParam);
}
github roemhildtg / vscode-arcgis-assistant / src / lib / PortalConnection.ts View on Github external
public async getItem(itemId : string) : Promise{
        const item = await getItem(itemId, {
            portal: this.restURL,
            authentication: this.authentication,
        });
        const itemData = await getItemData(itemId, {
            authentication: this.authentication,
            portal: this.restURL,
        });

        let data;
        if(typeof itemData === 'string'){
            try {
                data = JSON.parse(itemData);
            } catch(e){
                data = itemData;
            }
        } else {