How to use the @esri/arcgis-rest-portal.searchItems 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-search-command.js View on Github external
execute: function (query) {
    // construct the search call..
    return searchItems({
      searchForm: {
        q: query,
        start: 1,
        num: 10
      }
    })
    .then((response) => {
      // if we got results
      if (Array.isArray(response.results) && response.results.length)  {
        console.info(`${response.total} items found for "${query}".`);
        response.results.forEach((entry) => {
          console.info(`${entry.id} | ${entry.title}`);
        })
      } else {
        console.info(`No results found for "${query}".`);
      }
github Esri / arcgis-rest-js / demos / node-cli-item-management / index.js View on Github external
query.match(tag).in("tags");
          if (index !== tags.length - 1) {
            query.or();
          }
        });
        query.endGroup();
      }

      // format the search query for the search text
      if (searchText.length) {
        query.and().match(searchText);
      }

      console.log(chalk.blue(`Searching ArcGIS Online: ${query.toParam()}`));

      return searchItems({
        authentication: session,
        q: query,
        num: number
      })
      .then(response => {
        return { response, session };
      })
      .catch(err => {
        console.warn(err);
      })
    }
  );
github Esri / arcgis-rest-js / demos / tree-shaking-rollup / src / index.js View on Github external
import { searchItems } from "@esri/arcgis-rest-portal";

let element = document.createElement("div");
document.body.appendChild(element);

searchItems("water").then(response => {
  element.innerHTML = JSON.stringify(response); // false
});
github Esri / arcgis-rest-js / demos / webmap-checker-sapper / src / routes / webmaps / index.html View on Github external
const { session } = this.store.get();

      // redirect to the homepage unless the user is signed in
      if (!session) {
        this.redirect(302, "/");
        return;
      }

      // 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);

      // now we can search for webmaps. Sapper will wait until this promise
      // resolves before rendering the page.
      return (
        searchItems({
          q: `owner:${session.username} type:"Web Map"`,
          num: 100,
          authentication: userSession
        })
          // if there is an error we can retry the request with a fresh session
          // from /auth/exchange-token
          .catch(error => {
            return retryWithNewSession(error, this.fetch);
          })
          // then we can process out response.
          .then(response => {
            return {
              webmaps: response.results
            };
          })
github Esri / arcgis-rest-js / demos / tree-shaking-webpack / src / index.js View on Github external
import { searchItems } from "@esri/arcgis-rest-portal";

let element = document.createElement('div');
document.body.appendChild(element);

searchItems("water")
  .then(response => {
    element.innerHTML = JSON.stringify(response); // false
  })
github roemhildtg / vscode-arcgis-assistant / src / lib / PortalConnection.ts View on Github external
.and()
                .match('root')
                .in('ownerfolder')
                .and()
                .match(this.authentication.username)
                .in('owner');
        }
        const query = {
            num: 100,
            ...this.params,
            ...params,
            authentication: this.authentication,
            portal: this.restURL,
        };

        const {total} = await searchItems({
            ...query,
            num: 0,
        });

        const pages = Math.round(total / query.num);
        const promises = [];
        for (let i = 0; i <= pages; i ++) {
            promises.push(searchItems({
                ...query,
                start: 1 + (i * query.num),
            }).catch((e) => {
                console.log(`Error while searching items. \n ${e} \n`, query);
                return {};
            }));
        }
github roemhildtg / vscode-arcgis-assistant / src / lib / PortalConnection.ts View on Github external
num: 100,
            ...this.params,
            ...params,
            authentication: this.authentication,
            portal: this.restURL,
        };

        const {total} = await searchItems({
            ...query,
            num: 0,
        });

        const pages = Math.round(total / query.num);
        const promises = [];
        for (let i = 0; i <= pages; i ++) {
            promises.push(searchItems({
                ...query,
                start: 1 + (i * query.num),
            }).catch((e) => {
                console.log(`Error while searching items. \n ${e} \n`, query);
                return {};
            }));
        }

        return await Promise.all(promises).then((results) => {
            return results.reduce((previous : any, current : any) => {
                const features = current.results || [];
                return previous.concat(features);
            }, []);
        });

    }
github Esri / solution.js / packages / common / src / restHelpers.ts View on Github external
export function searchItems(
  search: string | portal.ISearchOptions | portal.SearchQueryBuilder
): Promise> {
  return portal.searchItems(search);
}