Which internal fields are available in CloudCode?

Which internal fields are available in CloudCode? I want to retrieve the backend URL.

CloudeCode provides you with the following internal fields:

  1. this
  2. CloudCode

Please see these examples.

console.log(JSON.stringify(this));

{ "appId": "5db98d1721956f4c4", "env": "testing", "name": "play_ground", "traceId": "T20191104124943bBRf5PyKAQBG7fVM8q", "source": "EDITOR_TEST", "backend": { "available": true, "instance": "5db98dc4771956f4c4", "url": "https://run-testing.journeyapps.com/api/v4/5db98d126f4c4", "token": "[expunged]", "authorization": "[expunged]", "DB": "[DB]" }, "userId": null, "DB": "[DB]" }

console.log(JSON.stringify(CloudCode));

{"ENQUEUE":"ENQUEUE","SCHEDULER":"SCHEDULER","WEBHOOK":"WEBHOOK","WEB":"WEB","APP":"APP","IDP":"IDP","EDITOR_TEST":"EDITOR_TEST","task":{"appId":"5db98d956f4c4","env":"testing","name":"play_ground"}}

This allows you to do things like:

    if (this.source === CloudCode.WEBHOOK) { console.log('Webhook'); }
1 Like