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

To help you get started, we’ve selected a few @esri/arcgis-rest-request 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 / packages / arcgis-rest-items / src / items.ts View on Github external
export function addItemData(
  requestOptions: IItemDataAddRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);

  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/update`;

  // Portal API requires that the 'data' be POSTed in a `file` form field.
  requestOptions.params = {
    file: requestOptions.data,
    ...requestOptions.params
  };

  return request(url, requestOptions);
}
/**
github Esri / arcgis-rest-js / packages / arcgis-rest-portal / src / util / generic-search.ts View on Github external
switch (searchType) {
    case "item":
      path = "/search";
      break;
    case "group":
      path = "/community/groups";
      break;
    default:
      // "users"
      path = "/portals/self/users/search";
      break;
  }
  url = getPortalUrl(options) + path;

  // send the request
  return request(url, options).then(r => {
    if (r.nextStart && r.nextStart !== -1) {
      r.nextPage = function() {
        let newOptions: ISearchOptions;

        if (
          typeof search === "string" ||
          search instanceof SearchQueryBuilder
        ) {
          newOptions = {
            q: search,
            start: r.nextStart
          };
        } else {
          newOptions = search;
          newOptions.start = r.nextStart;
        }
github Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / fetch-token.ts View on Github external
export function fetchToken(
  url: string,
  requestOptions: ITokenRequestOptions
): Promise {
  const options: IRequestOptions = requestOptions;
  // we generate a response, so we can't return the raw response
  options.rawResponse = false;

  return request(url, options).then((response: IFetchTokenRawResponse) => {
    const r: IFetchTokenResponse = {
      token: response.access_token,
      username: response.username,
      expires: new Date(
        // convert seconds in response to milliseconds and add the value to the current time to calculate a static expiration timestamp
        Date.now() + (response.expires_in * 1000 - 1000)
      ),
      ssl: response.ssl === true
    };
    if (response.refresh_token) {
      r.refreshToken = response.refresh_token;
    }

    return r;
  });
}
github Esri / arcgis-rest-js / packages / arcgis-rest-portal / src / sharing / access.ts View on Github external
// if the user wants to make the item private, it needs to be unshared from any/all groups as well
  if (requestOptions.access === "private") {
    requestOptions.params.groups = " ";
  }
  if (requestOptions.access === "org") {
    requestOptions.params.org = true;
  }
  // if sharing with everyone, share with the entire organization as well.
  if (requestOptions.access === "public") {
    // this is how the ArcGIS Online Home app sets public access
    // setting org = true instead of account = true will cancel out all sharing
    requestOptions.params.account = true;
    requestOptions.params.everyone = true;
  }
  return request(url, requestOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
if (typeof search === "string") {
    options.params.q = search;
  } else {
    options.params = search.searchForm;
    // mixin, giving user supplied requestOptions precedence
    options = {
      ...options,
      ...search
    };
  }

  // construct the search url
  const url = `${getPortalUrl(options)}/search`;

  // send the request
  return request(url, options);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / getAttachments.ts View on Github external
export function getAttachments(
  requestOptions: IGetAttachmentsOptions
): Promise<{ attachmentInfos: IAttachmentInfo[] }> {
  const options: IGetAttachmentsOptions = {
    httpMethod: "GET",
    ...requestOptions
  };

  // pass through
  return request(
    `${cleanUrl(options.url)}/${options.featureId}/attachments`,
    options
  );
}
github Esri / arcgis-rest-js / packages / arcgis-rest-portal / src / users / invitation.ts View on Github external
export function declineInvitation(
  requestOptions: IInvitationRequestOptions
): Promise {
  const username = encodeURIComponent(requestOptions.authentication.username);
  const portalUrl = getPortalUrl(requestOptions);
  const url = `${portalUrl}/community/users/${username}/invitations/${
    requestOptions.invitationId
  }/decline`;

  const options: IInvitationRequestOptions = { ...requestOptions };
  return request(url, options);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-portal / src / groups / protect.ts View on Github external
export function protectGroup(
  requestOptions: IGroupIdRequestOptions
): Promise<{ success: boolean }> {
  const url = `${getPortalUrl(requestOptions)}/community/groups/${
    requestOptions.id
  }/protect`;

  return request(url, requestOptions);
}
github Esri / solution.js / src / itemTypes / featureservice.ts View on Github external
layerList.forEach(layer => {
      requestsDfd.push(request(serviceUrl + "/" + layer["id"] + "?f=json", requestOptions));
    });
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function unprotectItem(
  requestOptions: IItemIdRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/unprotect`;
  return request(url, requestOptions);
}