Skip to content

Commit 240d2e6

Browse files
committed
Update docs
1 parent f594203 commit 240d2e6

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

docs/custom-actions/action-types.md

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,20 @@ With the JavaScript action, you can execute JavaScript code using a Node.js sand
616616

617617
<code>console.log(*line*)</code> / <code>echo(*line*)</code> - log a string to Action output
618618

619+
<code>stop()</code> - stops action execution and return response
620+
621+
<code>dont_save()</code> - marks current requests as [*Don't Save*](#dont-save), so it won't be stored or shown in the Webhook.site requests list
622+
623+
<code>respond(*content*, *status*, *headers*)</code> - stops action execution and return response
624+
625+
``` javascript
626+
respond('OK', 200, ['Content-Type: text/plain'])
627+
```
628+
629+
<code>set_response(*content*, *status*, *headers*)</code> - sets response, but doesn't stop action execution
630+
631+
#### Webhook.site Variables Functions
632+
619633
<code>set(*variable_name*, *value*)</code> - sets a Webhook.site variable for use in downstream actions
620634

621635
The following code would set the variable $myvar$ to `value`:
@@ -636,18 +650,48 @@ echo(await global('my-variable'))
636650

637651
<code>store(*variable_name*, *value*)</code> - stores the value of a Webhook.site Global Variable. Must be used async.
638652

639-
<code>stop()</code> - stops action execution and return response
653+
#### Webhook.site Database Functions
640654

641-
<code>dont_save()</code> - marks current requests as [*Don't Save*](#dont-save), so it won't be stored or shown in the Webhook.site requests list
655+
<code>db(*database_id*)</code> - interact with a [Webhook.site Database](/databases.html) instance. Returns a database connection in the form of a function that takes `query` and `params` arguments.
642656

643-
<code>respond(*content*, *status*, *headers*)</code> - stops action execution and return response
657+
```javascript
658+
mydb = await db('example_db')
659+
660+
users = await mydb('select * from users');
661+
console.log(users)
662+
// {
663+
// "result": [
664+
// {
665+
// "id": 1,
666+
// "name": "Jack Daniels"
667+
// },
668+
// {
669+
// "id": 2,
670+
// "name": "Elijah Craig"
671+
// }
672+
// ],
673+
// "error": null,
674+
// "rows": 2,
675+
// "time": 0
676+
// }
677+
678+
679+
for (user of users['result']) {
680+
console.log(user['name'])
681+
}
682+
// Jack Daniels
683+
// Elijah Craig
644684

645-
``` javascript
646-
respond('OK', 200, ['Content-Type: text/plain'])
685+
resp = await mydb(
686+
'insert into users (name) values (:name)',
687+
{
688+
"name": "Jim Beam"
689+
}
690+
)
691+
console.log(resp)
692+
// {"result":[[]],"error":null,"rows":1,"time":0}
647693
```
648694

649-
<code>set_response(*content*, *status*, *headers*)</code> - sets response, but doesn't stop action execution
650-
651695
#### Utility Modules
652696

653697
Code executed with the Webhook.site JavaScript action runs in a sandbox where the following utility libraries are available by using the `require()` function:

docs/news.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ Subscribe below to receive updates about improvements and new features on Webhoo
2424
</form>
2525
</div>
2626

27+
## 9 October 2025
28+
29+
* Added support for [Webhook.site Databases](/databases.html) in JavaScript. [More info here](/custom-actions/action-types.html#webhooksite-database-functions).
30+
* Fixed an error when adding invalid header data to the Modify Response action.
31+
2732
## 8 October 2025
2833

2934
* Added support for [Webhook.site Databases](/databases.html) in WebhookScript. [More info here](/webhookscript/functions/database.html).

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ nav:
8484
- Flow Control and Responses: webhookscript/functions/flow.md
8585
- Math and Numbers: webhookscript/functions/math.md
8686
- Network and HTTP: webhookscript/functions/network.md
87-
- Databases: webhookscript/functions/database.html
87+
- Databases: webhookscript/functions/database.md
8888
- Strings: webhookscript/functions/string.md
8989
- Custom Action Variables: webhookscript/functions/variables.md
9090
- Examples: custom-actions/examples.markdown

0 commit comments

Comments
 (0)