diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md index ce39d4bac..a3dcd7c6b 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md @@ -162,7 +162,7 @@ APIs that generate random numbers, random UUIDs, or the current date are _non-de For example, instead of this: -{{< tabs ".NET" Java >}} +{{< tabs ".NET" Java JavaScript >}} {{% codetab %}} @@ -186,6 +186,17 @@ string randomString = GetRandomString(); {{% /codetab %}} +{{% codetab %}} + +```javascript +// DON'T DO THIS! +const currentTime = new Date(); +const newIdentifier = uuidv4(); +const randomString = getRandomString(); +``` + +{{% /codetab %}} + {{< /tabs >}} Do this: @@ -214,6 +225,16 @@ String randomString = context.callActivity(GetRandomString.class.getName(), Stri {{% /codetab %}} +{{% codetab %}} + +```javascript +// Do this!! +const currentTime = context.getCurrentUtcDateTime(); +const randomString = yield context.callActivity(getRandomString); +``` + +{{% /codetab %}} + {{< /tabs >}} @@ -247,6 +268,24 @@ HttpResponse response = HttpClient.newBuilder().build().send(request, Ht {{% /codetab %}} +```javascript +// DON'T DO THIS! +// Accessing an Environment Variable (Node.js) +const configuration = process.env.MY_CONFIGURATION; + +fetch('https://postman-echo.com/get') + .then(response => response.text()) + .then(data => { + console.log(data); + }) + .catch(error => { + console.error('Error:', error); + }); + +``` + +{{% /codetab %}} + {{< /tabs >}} Do this: @@ -273,6 +312,16 @@ String data = ctx.callActivity(MakeHttpCall.class, "https://example.com/api/data {{% /codetab %}} +{{% codetab %}} + +```javascript +// Do this!! +const configuation = workflowInput.getConfiguration(); // imaginary workflow input argument +const data = yield ctx.callActivity(makeHttpCall, "https://example.com/api/data"); +``` + +{{% /codetab %}} + {{< /tabs >}}