osm-request icon indicating copy to clipboard operation
osm-request copied to clipboard

Node support

Open andrewharvey opened this issue 4 years ago • 3 comments

RequestException: ReferenceError: XMLHttpRequest is not defined

It looks like this library doesn't support use in node, would be nice to support it.

andrewharvey avatar Jun 11 '21 07:06 andrewharvey

Hello, thanks for this feedback. This is something we can work on. As a temporary solution, you can embed XMLHttpRequest on Node side, like done here : https://framagit.org/Pic4Carto/Pic4Review/-/blob/master/webpack.config.js#L57

PanierAvide avatar Jun 17 '21 06:06 PanierAvide

Thanks for the tip! For now I decided to directly call the API rather than using this library.

andrewharvey avatar Jun 17 '21 06:06 andrewharvey

Kind of a late hacky answer, but this worked for me:

  • yarn add w3c-xmlhttprequest
  • Insert this line before importing osm-request:
global.XMLHttpRequest = require("w3c-xmlhttprequest").XMLHttpRequest;

mogita avatar Oct 17 '23 12:10 mogita