When using the @commercetools/sdk-middleware-http it seems you need to include a polyfill for Buffer in your project if you need to use this package in a browser environment but this is not mentioned in the docs.
Expected Behavior
The docs should mention the Buffer polyfill requirement for browser environments.
Current Behavior
When using this package in a browser environment and using a middleware in a request with a payload, the application will crash because the Buffer object does not exist in the browser.
Context
This problem was discovered when working with the @commercetools-frontend/sdk package from the Merchant Center application kit.
Possible Solution
Add a note in the docs explaining a polyfill is required when using this package in a broswer environment. Also recommend a package to use (example)
Avoid using Buffer in the source code as suggested here
Description
When using the @commercetools/sdk-middleware-http it seems you need to include a polyfill for
Buffer
in your project if you need to use this package in a browser environment but this is not mentioned in the docs.Expected Behavior
The docs should mention the
Buffer
polyfill requirement for browser environments.Current Behavior
When using this package in a browser environment and using a middleware in a request with a payload, the application will crash because the
Buffer
object does not exist in the browser.Context
This problem was discovered when working with the
@commercetools-frontend/sdk
package from the Merchant Center application kit.Possible Solution
Buffer
in the source code as suggested here