Error: requires a fetch implementation

437
1
Jump to solution
07-16-2021 08:18 AM
GiorgioTodeschini
New Contributor

Hello Sirs,

I'm new in ArcGIS REST JS and I'm trying the first scripts following the tutorials. To do this try, I'm using the NodeJS environment.

Unfortunately, in all my tests, I always get the error

Error: `arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing `fetch`, `FormData`. We recommend installing the `node-fetch`, `isomorphic-form-data` modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.


I also try the much simple test that I found

import { geocode } from '@esri/arcgis-rest-geocoding';

geocode("LAX")
  .then((response=> {
    console.log(response);
  });

run by the command 'node mytestfile.js', but the result is always the same.

I installed the packages 'https://github.com/lquixada/cross-fetch' and 'https://github.com/form-data/isomorphic-form-data' so I can't understand what I wrong.

Could you please help me?
Thanks in advance

0 Kudos
1 Solution

Accepted Solutions
GavinRehkemper
Esri Contributor

Hi, did you follow the instructions on the top of the page here: https://esri.github.io/arcgis-rest-js/guides/node ?

Specifically, installing these modules:

npm install @esri/arcgis-rest-request @esri/arcgis-rest-auth cross-fetch isomorphic-form-data

View solution in original post

0 Kudos
1 Reply
GavinRehkemper
Esri Contributor

Hi, did you follow the instructions on the top of the page here: https://esri.github.io/arcgis-rest-js/guides/node ?

Specifically, installing these modules:

npm install @esri/arcgis-rest-request @esri/arcgis-rest-auth cross-fetch isomorphic-form-data

View solution in original post

0 Kudos