You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/developer/script-task-api.mdx
+78-24Lines changed: 78 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -238,8 +238,9 @@ if (hasBeenPaused) {
238
238
This allows you to achieve multiple semi-parallel code executions.
239
239
</Callout>
240
240
241
-
Like [`wait()`](#wait) but asynchronous, so it immediately continues with the next code instructions and does not block the specified timeout is finished.
242
-
In this sense, it is similar to the usual `setTimeout()` but only with a Promise. So, you can use `await` or `then()`.
241
+
Like [`wait()`](#wait) but asynchronous. So, it immediately continues with the next code instructions and does not block the execution.
242
+
In this sense, it is similar to the usual `setTimeout()` but instead of callbacks, it returns a _Promise_.
If the entire process is paused from the Management System, all script code is also paused until the process is resumed. If a pause occurs during a `networkRequest.X()`, the system stores the response and returns it when the process is resumed.
| `.get( "<url>", [<{options}>]): { response, body }` | Sends a GET-Request to a URL |
332
336
| `.post( "<url>", <{body}>, ["<content-type>"], [<{options}>]): { response, body } ` | Sends a POST-Request to a URL with a `body` (Object or String) |
333
337
| `.put( "<url>", <{body}>, ["<content-type>"], [<{options}>]): { response, body }` | Sends PUT-Request to URL with a `body` (Object or String) |
@@ -357,12 +361,7 @@ In case of a secure HTTPS connection, the `options` object has some [additional
357
361
358
362
The network functions only returnif the _response_ has a HTTP2xx status code. The methods return an object that contains two properties:`{ response, body }`
359
363
360
-
-`response`: is an object that contains meta information about the response,
361
-
including `.headers`, `.httpVersion`, `.method`, `.statusCode`,
362
-
`.statusMessage`, and `.url`. Because it resembles _IncomingMessage_, see the
-`response`: is an object that contains meta information about the response. It includes the following properties:`.rawHeaders`, `.rawTrailers`, `.httpVersionMajor`, `.httpVersionMinor`, `httpVersion`, `.method`, `.statusCode`, `.statusMessage`, `.url`, `.complete`, `.aborted`, `.upgrade`
366
365
-`body`: Body of the response
367
366
368
367
The functions throw an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) if:
@@ -404,21 +403,76 @@ try {
404
403
405
404
#### `networkRequest`: asychronous functions
406
405
407
-
The network functions are asynchronous, meaning a Promise is returned.
408
-
**Attention:** The `async/await` pattern should be used to handle this, **not**
409
-
the `.then()` and `.catch()`.
406
+
<Callout type='warning'>
407
+
The use of the asynchronous `networkRequest.X()` functions is only suitable for advanced users.
408
+
It makes code execution asynchronous.
409
+
This allows you to achieve multiple semi-parallel code executions.
410
+
</Callout>
410
411
411
-
Inside of a Script Task it is possible to send HTTP(S) requests to a given URL.
412
-
The prefered way of using `networkRequest` is with its synchronous methods, i.e. the functions wait until an answer is is received.
413
-
Since this are network requests, the completion of the methods sometimes need a while until the response is received.
412
+
Like the synchronous [`networkRequest.X()`](#networkRequest) functions but asynchronous. So, it immediately continues with the next code instructions and does not block the execution.
413
+
The functions return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with `{ response, body}` object.
414
+
Therefore, you can use `await`, `then()`, `catch()` or `finally()`.
415
+
Pausing behavior is the same as for `networkRequest.X()`.
| `.get( "<url>", [<{options}>]): { response, body }` | Sends a GET-Request to a URL |
418
-
| `.post( "<url>", <{body}>, ["<content-type>"], [<{options}>]): { response, body } ` | Sends a POST-Request to a URL with a `body` (Object or String) |
419
-
| `.put( "<url>", <{body}>, ["<content-type>"], [<{options}>]): { response, body }` | Sends PUT-Request to URL with a `body` (Object or String) |
420
-
| `.delete( "<url>", [<{options}>]): { response, body }` | Sends a DELETE-Request to a URL |
421
-
| `.head( "<url>", [<{options}>]): { response, body }` | Sends a HEAD-Request to a URL |
| `.getAsync( "<url>", [<{options}>]):Promise<{ response, body }>` | Sends a GET-Request to a URL |
420
+
| `.postAsync( "<url>", <{body}>, ["<content-type>"], [<{options}>]):Promise<{ response, body }>` | Sends a POST-Request to a URL with a `body` (Object or String) |
421
+
| `.putAsync( "<url>", <{body}>, ["<content-type>"], [<{options}>]):Promise<{ response, body }>` | Sends PUT-Request to URL with a `body` (Object or String) |
422
+
| `.deleteAsync( "<url>", [<{options}>]):Promise<{ response, body }>` | Sends a DELETE-Request to a URL |
423
+
| `.headAsync( "<url>", [<{options}>]):Promise<{ response, body }>` | Sends a HEAD-Request to a URL |
0 commit comments