Converting circular structure to JSON\n --> starting at object with constructor 'Object'\n |

Hello,

I am running a mock script on the api call. It works perfectly fine on the cloud mock server but gives error on the local mock server. It would be very helpful if anyone can point out if I am making any mistake or missing something.

Mock script

// read params (page+limit)
const page = Math.max(1, Number($$.mockRequest.getParam("page")) || 1);
const limit = Math.max(1, Math.min(100, Number($$.mockRequest.getParam("limit")) || 25));
const offset = (page - 1) * limit;

// pretend there are 1,000,000 rows
const TOTAL = 1000000;
const count = Math.max(0, Math.min(limit, TOTAL - offset));


const items = [];
for (let i = 0; i < count; i++) {
  const id = offset + i + 1;
  items.push({
    id: id,
    email: `user${id}@example.com`
  });
}
const responseData = {
  emailAccounts: items,
  total: TOTAL,
  limit,
  currPage: page
};

$$.mockResponse.setCode(200);

// return plain JSON
$$.mockResponse.setBody(responseData);

Error I am getting on the local mock server


{
  "apidogError": {
    "code": 500001,
    "message": "Converting circular structure to JSON\n    --> starting at object with constructor 'Object'\n    |     property 'parser' -> object with constructor 'Object'\n    --- property 'socket' closes the circle"
  }
}

Hello Hussain,

Thank you for your feedback. This issue has been fixed in the latest version. Please download the latest version from our official website to resolve it. We apologize for any inconvenience caused.

Best regards,
Apidog Support