mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-04 01:18:20 +02:00
docs: Add cURL command to ApiRequest component.
This commit is contained in:
parent
1eb4ae99ec
commit
d0c4eb2637
@ -18,19 +18,31 @@ import CodeBlock from '@theme/CodeBlock';
|
|||||||
const indentation = 2;
|
const indentation = 2;
|
||||||
|
|
||||||
const Component = ({ verb, payload, url, title }) => {
|
const Component = ({ verb, payload, url, title }) => {
|
||||||
const verbUpper = verb?.toUpperCase() || ""
|
const verbUpper = verb?.toUpperCase() || '';
|
||||||
const prettyPayload = JSON.stringify(payload, null, indentation)
|
const prettyPayload = JSON.stringify(payload, null, indentation);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs groupId="api-request">
|
<Tabs groupId="api-request">
|
||||||
<TabItem value="http" label="HTTP">
|
<TabItem value="http" label="HTTP">
|
||||||
<CodeBlock language="http" title={title}>
|
<CodeBlock language="http" title={title}>
|
||||||
{`${verbUpper} <unleash-url>/${url}
|
{`
|
||||||
|
${verbUpper} <unleash-url>/${url}
|
||||||
Authorization: <API-token>
|
Authorization: <API-token>
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
|
|
||||||
${prettyPayload}
|
${prettyPayload}
|
||||||
`}
|
`.trim()}
|
||||||
|
</CodeBlock>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="curl" label="cURL">
|
||||||
|
<CodeBlock language="bash" title={title}>
|
||||||
|
{`
|
||||||
|
curl -H "Content-Type: application/json" \\
|
||||||
|
-H "Authorization: <API-token>" \\
|
||||||
|
-X ${verbUpper}
|
||||||
|
-d '${prettyPayload}' \\
|
||||||
|
<unleash-url>/${url}
|
||||||
|
`.trim()}
|
||||||
</CodeBlock>
|
</CodeBlock>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="httpie" label="HTTPie">
|
<TabItem value="httpie" label="HTTPie">
|
||||||
@ -38,7 +50,7 @@ ${prettyPayload}
|
|||||||
{`echo '${prettyPayload}' \\
|
{`echo '${prettyPayload}' \\
|
||||||
| http ${verbUpper} \\
|
| http ${verbUpper} \\
|
||||||
<unleash-url>/${url} \\
|
<unleash-url>/${url} \\
|
||||||
Authorization:<API-token>`}
|
Authorization:<API-token>`.trim()}
|
||||||
</CodeBlock>
|
</CodeBlock>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
Loading…
Reference in New Issue
Block a user