Noel Yap
Noel Yap

Reputation: 19758

How do I copy a request object to the response in mountebank?

I'm using the following mountebank stubs config:

const stubs = [
  {
    responses: [
      {
        is: {
          statusCode: 200,
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            messageHeader: "${MESSAGE_HEADER}",
          }),
        },
        _behaviors: {
          copy: [
            {
              from: "body",
              into: "${MESSAGE_HEADER}",
              using: {
                method: "jsonpath",
                selector: "$.messageHeader",
              },
            },
          ],
        },
      },
    ],
  },
];

With the request:

{
  "messageHeader": {
    "userId": "USER_ID",
    "orgAlias": "ORG_ALIAS"
  },
}

the response is coming back as:

{"messageHeader":"[object Object]"}

How do I get it to inject the messageHeader JSON object itself?

Upvotes: 0

Views: 155

Answers (0)

Related Questions