How to use @commercetools/http-user-agent - 3 common examples

To help you get started, we’ve selected a few @commercetools/http-user-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / nodejs / packages / sdk-middleware-user-agent / src / user-agent.ts View on Github external
export default function createUserAgentMiddleware(
  options: UserAgentMiddlewareOptions
): Middleware {
  const userAgent = createHttpUserAgent({
    name: 'commercetools-js-sdk',
    ...options,
  })

  return (next: Dispatch): Dispatch => (
    request: MiddlewareRequest,
    response: MiddlewareResponse
  ) => {
    const requestWithUserAgent = {
      ...request,
      headers: {
        ...request.headers,
        'User-Agent': userAgent,
      },
    }
    next(requestWithUserAgent, response)

@commercetools/http-user-agent

Creates a proper HTTP User-Agent

MIT
Latest version published 2 years ago

Package Health Score

66 / 100
Full package analysis

Popular @commercetools/http-user-agent functions