DeepLcom / deepl-node

Official Node.js library for the DeepL language translation API.
MIT License
370 stars 22 forks source link

The translation API returns an empty body in Cloudflare Workers. #27

Closed ashishwhydonate closed 1 year ago

JanEbbing commented 1 year ago

Hey @ashishwhydonate , thanks for the report. Could you give some details on your environment (which node version etc), and how your example is set up? I just set up a hello world project on a cloudflare worker, and needed to set node_compat = true in the wrangler.toml to be able to publish to the worker in the first place. Once I did this, I now get

A request to the Cloudflare API (/accounts/<accid>/workers/scripts/deepl-api-test) failed.

  Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
    at worker.js:4597:11 in checkTypeSupport
    at worker.js:4618:38 in
  node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
    at worker.js:8:56 in __init
    at worker.js:9091:5 in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
    at worker.js:8:56 in __init
    at worker.js:10074:5 in node-modules-polyfills:http
    at worker.js:8:56 in __init
    at worker.js:10178:21 in node-modules-polyfills-commonjs:http
    at worker.js:11:50 in __require
    at worker.js:10605:18 in ../node_modules/deepl-node/dist/index.js
   [code: 10021]

  If you think this is a bug, please open an issue at:
  https://github.com/cloudflare/workers-sdk/issues/new/choose

which matches some other report we had on this, so I'd be curious how you got it to execute an API request in the first place.

JanEbbing commented 1 year ago

Also, please see my response in https://github.com/DeepLcom/deepl-node/issues/14

JanEbbing commented 1 year ago

I responded in #14 with an update, closing this issue for now.