8000 Trouble polyfill fetch in Node with typescript · Issue #666 · Esri/arcgis-rest-js · GitHub
[go: up one dir, main page]

Skip to content
Trouble polyfill fetch in Node with typescript #666
@ajturner

Description

@ajturner

I'm attempting to build an express app with Node 11. I've added the following to my app.js while my arcgis-rest-js calls are made in various Util modules. I never directly call request - only using the geocoding and Portal module methods.

const fetch = require('node-fetch');
import * as RestRequest from '@esri/arcgis-rest-request';

// use node-fetch for each request instead of relying on a global
RestRequest.setDefaultRequestOptions({ fetch })

but I still get the error

UnhandledPromiseRejectionWarning: 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.

@dbouwman @patrickarlt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0