mirror of
https://github.com/morten-olsen/http.md.git
synced 2026-02-08 00:46:28 +01:00
fix: fix parsing issue
This commit is contained in:
@@ -176,6 +176,13 @@ Within your markdown document, the following variables are available in the Hand
|
|||||||
|
|
||||||
::raw-md[./examples/with-template.md]
|
::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.)_
|
_(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:**
|
**2. Displaying a status code in markdown text:**
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
```http id=createItem json
|
```http #createItem,json
|
||||||
POST https://httpbin.org/post
|
POST https://httpbin.org/post
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{"name": "My New Item"}
|
{"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:
|
Now, let's fetch the item using a (mocked) ID from the response:
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ const httpHandler: ExecutionHandler = ({
|
|||||||
const content = template(context);
|
const content = template(context);
|
||||||
const [head, body] = content.split('\n\n');
|
const [head, body] = content.split('\n\n');
|
||||||
const [top, ...headerItems] = head.split('\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(
|
const headers = Object.fromEntries(
|
||||||
headerItems.map((header) => {
|
headerItems.map((header) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user