Update limitation for js

Update limitation for js

Signed-off-by: kaibocai <89094811+kaibocai@users.noreply.github.com>
This commit is contained in:
kaibocai 2024-01-27 07:39:40 -06:00 committed by GitHub
parent 77a9d85175
commit fab5b197d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 50 additions and 1 deletions

View File

@ -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<String> 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 >}}