How to use the @commercetools/sdk-middleware-http.getErrorByCode function in @commercetools/sdk-middleware-http

To help you get started, we’ve selected a few @commercetools/sdk-middleware-http 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 / merchant-center-application-kit / packages / sdk / src / test-utils / test-utils.spec.ts View on Github external
beforeEach(() => {
        const BadRequestError = getErrorByCode(400);
        const error = new BadRequestError('Invalid parameter');
        const testMiddleware = createTestMiddleware([
          // @ts-ignore
          { action: { type: 'another-action' } },
          {
            action: sdkActions.get({ uri: '/foo/1' }),
            error,
          },
          {
            action: sdkActions.post({
              uri: '/foo',
              payload: JSON.stringify({ foo: 'bar' }),
            }),
            response: { foo: 'bar' },
          },
        ]);
github commercetools / nodejs / packages / sdk-auth / src / auth.js View on Github external
static _createResponseError(
    { message = 'Unexpected non-JSON error response', ...rest }: Object,
    uri: string,
    statusCode: number
  ): HttpErrorType {
    const errorMessage = statusCode === 404 ? `URI not found: ${uri}` : message

    let ResponseError = getErrorByCode(statusCode)
    if (!ResponseError) ResponseError = getErrorByCode(0)

    return new ResponseError(errorMessage, rest)
  }
github commercetools / nodejs / packages / sdk-auth / src / auth.js View on Github external
static _createResponseError(
    { message = 'Unexpected non-JSON error response', ...rest }: Object,
    uri: string,
    statusCode: number
  ): HttpErrorType {
    const errorMessage = statusCode === 404 ? `URI not found: ${uri}` : message

    let ResponseError = getErrorByCode(statusCode)
    if (!ResponseError) ResponseError = getErrorByCode(0)

    return new ResponseError(errorMessage, rest)
  }

@commercetools/sdk-middleware-http

Middleware for http requests, to use with @commercetools/sdk-client

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis