mirror of https://github.com/dapr/docs.git
Update limitation for js
Update limitation for js Signed-off-by: kaibocai <89094811+kaibocai@users.noreply.github.com>
This commit is contained in:
parent
77a9d85175
commit
fab5b197d2
|
@ -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 >}}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue