sdk-middleware-correlation-id
Middleware add a correlation id to requests.
Install
Node.js
npm install --save @commercetools/sdk-middleware-correlation-id
Browser
<script src="https://unpkg.com/@commercetools/sdk-middleware-correlation-id/dist/commercetools-sdk-middleware-correlation-id.umd.min.js"></script>
<script>
// global: CommercetoolsSdkMiddlewareCorrelationId
</script>
createCorrelationIdMiddleware(options)
Creates a middleware to add a correlation id to executed requests.
Usage example
import { createClient } from '@commercetools/sdk-client'
import { createCorrelationIdMiddleware } from '@commercetools/sdk-middleware-correlation-id'
import { createAuthMiddleware } from '@commercetools/sdk-middleware-auth'
import { createHttpMiddleware } from '@commercetools/sdk-middleware-http'
const client = createClient({
middlewares: [
createAuthMiddleware({...}),
createCorrelationIdMiddleware({
generate: () => `prefix/${uuid()}/postifx`
}),
createHttpMiddleware({...}),
],
})