Query.get retorna undefined()

I will be grateful if someone can explain to me why query.get() returns undefined and when using JSON.stringify it prints the object in string format.

Moralis.Cloud.define(“testGet”, async (request) => {
const logger = Moralis.Cloud.getLogger();
const query = new Moralis.Query(“PolygonTransactions”);
const result = await query.get(“6IkfcdBnAdtUgkq5SVVMHrQr”);
logger.info("--------------------------------------------------");
logger.info(result); // print undefined
logger.info(JSON.stringify(result)); // print object in string format
logger.info("--------------------------------------------------");
return result;
});

LOG

  1. 2022-04-20T12:25:40.947Z - --------------------------------------------------
  2. 2022-04-20T12:25:40.946Z - {“block_timestamp”:{"__type":“Date”,“iso”:“2022-04-19T21:20:19.000Z”},“hash”:“0xcdcc4a061902d860599ad63e65390789e86318a181022697ca092eb268c7aa9f”,“nonce”:189,“block_hash”:“0x251ca5b66475390e8c26ed211c1954536c01fefcf44aaba572703e4598bd0491”,“block_number”:26003271,“transaction_index”:6,“from_address”:“0xe35a73646e8a5997feb40a85c787a6e1bad15191”,“to_address”:“0x2f6b8030be7b58fffd082656850aa2189e481f29”,“value”:“10000000000000000”,“gas_price”:2500000010,“receipt_status”:1,“gas”:32436,“input”:“0x7b226f726465725f6964223a22485845576e73337831723559383746493538624e784e3637227d”,“confirmed”:true,“order_id”:“HXEWns3x1r5Y87FI58bNxN67”,“createdAt”:“2022-04-19T21:20:20.363Z”,“updatedAt”:“2022-04-19T21:28:44.818Z”,“receipt_contract_address”:null,“receipt_cumulative_gas_used”:2231461,“receipt_gas_used”:21624,“receipt_root”:null,“transfer_index”:[26003271,6],“objectId”:“6IkfcdBnAdtUgkq5SVVMHrQr”}
  3. 2022-04-20T12:25:40.945Z - undefined
  4. 2022-04-20T12:25:40.942Z - --------------------------------------------------

it is a bug in logger, that is why it prints undefined, it is not undefined as it works with the next line

1 Like