mailerlite / mailerlite-nodejs

MIT License
32 stars 7 forks source link

Library is not compatible with CloudFlare Workers / Vercel Edge functions #31

Open emmems opened 1 year ago

emmems commented 1 year ago
lewandom commented 10 months ago

More detailed error from a Next.js app, API route:

 [AxiosError: There is no suitable adapter to dispatch the request since :
- adapter xhr is not supported by the environment
- adapter http is not available in the build] {
  message: 'There is no suitable adapter to dispatch the request since :\n- adapter xhr is not supported by the environment\n- adapter http is not available in the build',
  name: 'AxiosError',
  code: 'ERR_NOT_SUPPORT'
}

Next.js edge runtime does not support full Node.js API. In particular, it doesn't support http module. It does support Fetch API though: https://nextjs.org/docs/app/api-reference/edge.

With Fetch API becoming stable in Node.js 21, it'd be nice to declare axios as an optional dependency and use Fetch API as the default request caller.

multiplehats commented 7 months ago

Just ran into this issue too, better to use the native fetch API instead of Axios :?

isitgeorge commented 6 months ago

Just ran into this - a potentially quicker fix could be to use this adapter that I have used with other libraries that rely on Axios, however would require some work to either pass the adapter in or expose the Axios object.

https://www.npmjs.com/package/@haverstack/axios-fetch-adapter