fix: fix parsing issue

This commit is contained in:
Morten Olsen
2025-05-18 21:11:41 +02:00
parent 68f5025527
commit 5d485acc97
3 changed files with 11 additions and 3 deletions

View File

@@ -176,6 +176,13 @@ Within your markdown document, the following variables are available in the Hand
::raw-md[./examples/with-template.md]
<details>
<summary>Output</summary>
::raw-md[./examples/with-template.md]{render}
</details>
_(Note: `httpbin.org/post` wraps the JSON sent in a "json" field in its response. If your API returns the ID directly at the root of the JSON body, you'd use `{{responses.createItem.body.id}}` assuming the `createItem` request had the `json` option.)_
**2. Displaying a status code in markdown text:**

View File

@@ -1,11 +1,11 @@
```http id=createItem json
```http #createItem,json
POST https://httpbin.org/post
Content-Type: application/json
{"name": "My New Item"}
```
The new item ID is: {{responses.createItem.body.json.name}}
The new item ID is: {{response.body.json.name}}
Now, let's fetch the item using a (mocked) ID from the response:

View File

@@ -33,7 +33,8 @@ const httpHandler: ExecutionHandler = ({
const content = template(context);
const [head, body] = content.split('\n\n');
const [top, ...headerItems] = head.split('\n');
const [method, url] = top.split(' ');
const [method, ...urlParts] = top.split(' ');
const url = urlParts.join(' ').trim();
const headers = Object.fromEntries(
headerItems.map((header) => {