Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copied request object coming back as [object Object] #756

Open
noel-yap opened this issue Feb 23, 2024 · 0 comments
Open

Copied request object coming back as [object Object] #756

noel-yap opened this issue Feb 23, 2024 · 0 comments

Comments

@noel-yap
Copy link

Duplicated from https://stackoverflow.com/questions/78044733/how-do-i-copy-a-request-object-to-the-response-in-mountebank

Expected behaviour

Request object properly injected into response. Eg:

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

...

Actual behaviour

String representation of request object injected into response. Eg:

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

...

Steps to reproduce

Use the following 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 following request:

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

...

Software versions used

OS         : Darwin Kernel Version 23.3.0
mountebank : 2.9.1

Log contents in mb.log when running mb --loglevel debug

{"level":"info","message":"[mb:2525] mountebank v2.9.1 now taking orders - point your browser to http://localhost:2525/ for help","timestamp":"2024-02-23T01:37:56.412Z"}
{"level":"info","message":"[mb:2525] POST /imposters","timestamp":"2024-02-23T01:37:56.439Z"}
{"level":"info","message":"[http:2526 Xifin] Open for business...","timestamp":"2024-02-23T01:37:56.443Z"}
{"level":"info","message":"[http:2526 Xifin] ::1:58532 => POST /test/accession/generatetoken?orgalias=ORG_ALIAS","timestamp":"2024-02-23T01:37:59.192Z"}
{"level":"info","message":"[http:2526 Xifin] ::1:58534 => POST /test/patient/restful/checkPatientEligibility?orgalias=ORG_ALIAS","timestamp":"2024-02-23T01:37:59.403Z"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant