Skip to content

Commit

Permalink
docs(fix): remove duplification
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Sep 9, 2024
1 parent 3639181 commit e732f42
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions docs/docs/scripts/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,77 +63,6 @@ So want to write a file in the `http` directory, you can use a relative path:
const fs = require("fs");
fs.writeFileSync("../http/my-file.txt", "Hello, world!");
```

## Pre-request

```http title="./pre-request-example.http"
# @name REQUEST_ONE
< {%
var crypto = require('crypto');
var fs = require('fs');
var TOKEN = fs.readFileSync('TOKEN.txt', 'utf8').trim();
request.variables.set('GORILLA', TOKEN);
request.variables.set('PASSWORD', crypto.randomBytes(16).toString('hex'));
%}
< ./pre-request.js
POST https://httpbin.org/post HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer Foo:bar
{
"token": "{{GORILLA}}",
"password": "{{PASSWORD}}",
"deep": {
"nested": [
{
"key": "foo"
},
{
"key": "{{BONOBO}}"
}
]
}
}
###
# @name REQUEST_TWO
POST https://httpbin.org/post HTTP/1.1
accept: application/json
content-type: application/json
{
"token": "{{REQUEST_ONE.response.body.$.json.token}}",
"nested": "{{REQUEST_ONE.response.body.$.json.deep.nested[1].key}}",
"gorilla": "{{GORILLA}}"
}
```

:::tip

Variables set via `request.variables.set` are only available in the current request.

:::

```javascript title="./pre-request.js"
client.global.set("BONOBO", "bar");
```

:::tip

Variables set via `client.global.set` are available in all requests and
persist between neovim restarts.

To clear a global variable,
run [`lua require('kulala').scripts_clear_global('BONOBO')`](../usage/public-methods#scripts_clear_global).

:::

```plaintext title="./TOKEN.txt"
THIS_IS_SOME_TOKEN_VALUE_123
```

## Pre-request

```http title="./pre-request-example.http"
Expand Down

0 comments on commit e732f42

Please sign in to comment.