FHIR/fhir.js

ReferenceError: fetch is not defined in nativeFhir.js when running in node

oliveregger opened this issue · 2 comments

when I use nativeFhir.js as mentioned in the example I get an error when running in node:

ReferenceError: fetch is not defined
at /Users/oliveregger/Documents/github/fhirtscmd/node_modules/fhir.js/src/adapters/native.js:61:7
at new Promise ()
at http (/Users/oliveregger/Documents/github/fhirtscmd/node_modules/fhir.js/src/adapters/native.js:58:12)
at /Users/oliveregger/Documents/github/fhirtscmd/node_modules/fhir.js/src/middlewares/http.js:9:67
at /Users/oliveregger/Documents/github/fhirtscmd/node_modules/fhir.js/src/middlewares/core.js:68:24

when adding the two imports below as mentioned in https://stackoverflow.com/questions/36484156/es6-fetch-is-undefined in nativeFhir.js the code is working:

require('es6-promise').polyfill();
require('isomorphic-fetch');

Thank you. Can you provide PR for this fix!

I'm sorry, I can't reproduce the problem anymore, I switched to the node Adaptor which works fine and for the angular version I built another adapter, so I close the problem.