Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}".`);
}
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);
})
}
);
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
});
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
};
})
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
})
.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 {};
}));
}
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);
}, []);
});
}
export function searchItems(
search: string | portal.ISearchOptions | portal.SearchQueryBuilder
): Promise> {
return portal.searchItems(search);
}