ArcGIS REST JS

repository·main·Indexed 18 days ago

https://github.com/esri/arcgis-rest-js

A collection of compact, modular JavaScript wrappers for the ArcGIS REST API, compatible with Node.js and modern browsers. Version 4.0.0 includes specialized packages for geocoding, elevation, demographics, places, portal items, and feature services, as well as utilities for authentication and environment-compatible fetch and form-data handling.

Tokens
73.5K
Snippets
244
Records
379
Agent score
63%

What's inside arcgis-rest-js

  1. Overview of @esri/arcgis-rest-js

    main
    The @esri/arcgis-rest-js library provides compact, modular JavaScript wrappers for the ArcGIS REST API. It is designed to run in both Node.js and modern web browsers, allowing developers to interact with ArcGIS services using standard JavaScript patterns.
  2. Understand the purpose of @esri/arcgis-rest-form-data

    main
    The @esri/arcgis-rest-form-data package provides a consistent way to access FormData, File, and Blob across different environments. It wraps the formdata-node package to ensure compatibility with Node.js (version 12.16+) and various web bundlers, while providing consistent TypeScript types based on browser standards.
  3. Understand the Post Message Authentication Specification

    main

    The Post Message Authentication protocol allows an embedded application to request credentials from a parent (HOST) application using the postMessage API.

    For security, the HOST application must only respond if:

    1. The event.origin of the message is a location that the HOST trusts.
    2. The message type is exactly arcgis:auth:requestCredential.

    If these conditions are not met, the HOST application should ignore the message and send no response.

  4. Environment compatibility for @esri/arcgis-rest-fetch

    main

    The package is designed to work across multiple runtimes and bundlers using conditional exports:

    • Node.js: Uses the exports field. It uses import() to load node-fetch for ESM/CommonJS compatibility.
    • Bundlers (Webpack, Rollup, Parcel):
      • ESM: Provided via the module and import conditions (exposing browser globals or node-fetch).
      • CJS: Provided via the browser and require conditions (exposing browser globals or node-fetch).

    This ensures that in a browser environment, you get browser-native globals, while in Node.js, you get the node-fetch implementation.

  5. Environment compatibility for @esri/arcgis-rest-form-data

    main

    The package uses conditional exports to support different runtimes and bundlers:

    • Node.js (12.16+): Uses the exports field to resolve to formdata-node via import or require conditions.
    • Modern Bundlers (Rollup, Parcel v2, Webpack): Use the module or exports conditions to access an ESM module that exposes FormData, File, and Blob from the global object.
    • Legacy Bundlers (Parcel v1, Browserify): Use the browser condition to access a CJS module that exposes FormData, File, and Blob from the global object.
  6. Migrate from @esri/arcgis-rest-auth to @esri/arcgis-rest-request

    main
    The @esri/arcgis-rest-auth package is deprecated as of v4.0.0 of ArcGIS REST JS. Authentication helpers have been moved and are now part of the @esri/arcgis-rest-request package. If you are starting a new project or upgrading, you should use @esri/arcgis-rest-request for authentication functionality instead of this package.