How to use the @esri/arcgis-rest-request.cleanUrl 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-geocoding / src / reverse.ts View on Github external
if (isLocationArray(coords)) {
    options.params.location = coords.join();
  } else if (isLocation(coords)) {
    if (coords.lat) {
      options.params.location = coords.long + "," + coords.lat;
    }
    if (coords.latitude) {
      options.params.location = coords.longitude + "," + coords.latitude;
    }
  } else {
    // if input is a point, we can pass it straight through, with or without a spatial reference
    options.params.location = coords;
  }

  return request(`${cleanUrl(options.endpoint)}/reverseGeocode`, options);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / addAttachment.ts View on Github external
export function addAttachment(
  requestOptions: IAddAttachmentOptions
): Promise<{ addAttachmentResult: IEditFeatureResult }> {
  const options: IAddAttachmentOptions = {
    params: {},
    ...requestOptions
  };

  // `attachment` --> params: {}
  options.params.attachment = requestOptions.attachment;

  return request(
    `${cleanUrl(options.url)}/${options.featureId}/addAttachment`,
    options
  );
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / query.ts View on Github external
"sqlFormat",
      "returnExceededLimitFeatures",
      "f"
    ],
    {
      httpMethod: "GET",
      params: {
        // set default query parameters
        where: "1=1",
        outFields: "*",
        ...requestOptions.params
      }
    }
  );

  return request(`${cleanUrl(requestOptions.url)}/query`, queryOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / UserSession.ts View on Github external
constructor(options: IUserSessionOptions) {
    this.clientId = options.clientId;
    this._refreshToken = options.refreshToken;
    this._refreshTokenExpires = options.refreshTokenExpires;
    this.username = options.username;
    this.password = options.password;
    this._token = options.token;
    this._tokenExpires = options.tokenExpires;
    this.portal = options.portal
      ? cleanUrl(options.portal)
      : "https://www.arcgis.com/sharing/rest";
    this.ssl = options.ssl;
    this.provider = options.provider || "arcgis";
    this.tokenDuration = options.tokenDuration || 20160;
    this.redirectUri = options.redirectUri;
    this.refreshTokenTTL = options.refreshTokenTTL || 1440;

    this.trustedServers = {};
    // if a non-federated server was passed explicitly, it should be trusted.
    if (options.server) {
      // if the url includes more than '/arcgis/', trim the rest
      const root = this.getServerRootUrl(options.server);

      this.trustedServers[root] = {
        token: options.token,
        expires: options.tokenExpires
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / updateAttachment.ts View on Github external
export function updateAttachment(
  requestOptions: IUpdateAttachmentOptions
): Promise<{ updateAttachmentResult: IEditFeatureResult }> {
  const options: IUpdateAttachmentOptions = {
    params: {},
    ...requestOptions
  };

  // `attachment` and `attachmentId` --> params: {}
  options.params.attachment = requestOptions.attachment;
  options.params.attachmentId = requestOptions.attachmentId;

  return request(
    `${cleanUrl(options.url)}/${options.featureId}/updateAttachment`,
    options
  );
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / queryRelated.ts View on Github external
requestOptions,
    ["objectIds", "relationshipId", "definitionExpression", "outFields"],
    {
      httpMethod: "GET",
      params: {
        // set default query parameters
        definitionExpression: "1=1",
        outFields: "*",
        relationshipId: 0,
        ...requestOptions.params
      }
    }
  );

  return request(
    `${cleanUrl(requestOptions.url)}/queryRelatedRecords`,
    options
  );
}
github Esri / arcgis-rest-js / packages / arcgis-rest-geocoding / src / bulk.ts View on Github external
requestOptions.addresses.forEach(address => {
    options.params.addresses.records.push({ attributes: address });
  });

  // the SAS service doesnt support anonymous requests
  if (
    !requestOptions.authentication &&
    options.endpoint === ARCGIS_ONLINE_GEOCODING_URL
  ) {
    return Promise.reject(
      "bulk geocoding using the ArcGIS service requires authentication"
    );
  }

  return request(
    `${cleanUrl(options.endpoint)}/geocodeAddresses`,
    options
  ).then(response => {
    if (options.rawResponse) {
      return response;
    }
    const sr = response.spatialReference;
    response.locations.forEach(function(address: { location: IPoint }) {
      if (address.location) {
        address.location.spatialReference = sr;
      }
    });
    return response;
  });
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / query.ts View on Github external
export function getFeature(
  requestOptions: IGetFeatureOptions
): Promise {
  const url = `${cleanUrl(requestOptions.url)}/${requestOptions.id}`;

  // default to a GET request
  const options: IGetFeatureOptions = {
    ...{ httpMethod: "GET" },
    ...requestOptions
  };
  return request(url, options).then((response: any) => {
    if (options.rawResponse) {
      return response;
    }
    return response.feature;
  });
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / deleteAttachments.ts View on Github external
export function deleteAttachments(
  requestOptions: IDeleteAttachmentsOptions
): Promise<{ deleteAttachmentResults: IEditFeatureResult[] }> {
  const options: IDeleteAttachmentsOptions = {
    params: {},
    ...requestOptions
  };

  // `attachmentIds` --> params: {}
  options.params.attachmentIds = requestOptions.attachmentIds;

  return request(
    `${cleanUrl(options.url)}/${options.featureId}/deleteAttachments`,
    options
  );
}
github Esri / arcgis-rest-js / packages / arcgis-rest-feature-layer / src / getLayer.ts View on Github external
export function getLayer(
  options: ILayerRequestOptions
): Promise {
  return request(cleanUrl(options.url), options);
}