commercelayer-sdk
commercelayer-sdk copied to clipboard
Remove Axios to make isomorphic ?
Any chance you can build a isomorphic SDK here? Currently, you use axios for the fetch in client.ts, which makes it impossible to use this SDK on the newer edge platforms like Cloudflare Workers (NextJs Edge also, which runs on Cloudflare) or Deno. I believe if you just switched the client to simply use standard fetch, it would work fine on Cloudflare Workers/Deno.
Hi @osseonews currently an isomorphic SDK is not in our plans but in the latest version of the SDK we added the adapter
option that can be used when creating the client to define e acustom adapter for Axios (1.x)
fetch doesn't support proxy feature, and this lib use proxy stuff from axios;
fetch minimal node.js version is 18;
Hi @suhaotian 👋
If we will add the support for fetch we'll modify also the support for proxies or we will remove it at all for the moment.
The SDK version which will include the support for fetch will work only with Node.js >=20.x
Commenting to track this issue and show support for this change. I'm currently writing fetch requests to commerce layer in server components to take advantage of NextJS RSCs. Would be great to use this library instead.
@suhaotian I think I will give xior
a try (well, I'll try to find time to do it 🙂)
@pviti Thanks for give a try of xior!
I clone the code, after install and run pnpm test, but test failed, any documentation of how to run tests locally?
You need a .env
file in your project root dir with the following variables:
CL_SDK_ORGANIZATION=<your-organization-slug>
CL_SDK_CLIENT_ID=<application-client-id>
CL_SDK_CLIENT_SECRET=<application-client-secret>
Tests execute some real calls to the API so you should use a TEST application (you can create one inside the Commerce Layer's dashboard)
@pviti Thanks
Now it's work, but still some tests failed, what I missing?