Skip to content

Commit

Permalink
docs: Add cURL command to ApiRequest component.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Feb 10, 2022
1 parent 1eb4ae9 commit d0c4eb2
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions website/src/components/ApiRequest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,39 @@ import CodeBlock from '@theme/CodeBlock';
const indentation = 2;

const Component = ({ verb, payload, url, title }) => {
const verbUpper = verb?.toUpperCase() || ""
const prettyPayload = JSON.stringify(payload, null, indentation)
const verbUpper = verb?.toUpperCase() || '';
const prettyPayload = JSON.stringify(payload, null, indentation);

return (
<Tabs groupId="api-request">
<TabItem value="http" label="HTTP">
<CodeBlock language="http" title={title}>
{`${verbUpper} <unleash-url>/${url}
{`
${verbUpper} <unleash-url>/${url}
Authorization: <API-token>
content-type: application/json
${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>
</TabItem>
<TabItem value="httpie" label="HTTPie">
<CodeBlock language="bash" title={title}>
{`echo '${prettyPayload}' \\
| http ${verbUpper} \\
<unleash-url>/${url} \\
Authorization:<API-token>`}
Authorization:<API-token>`.trim()}
</CodeBlock>
</TabItem>
</Tabs>
Expand Down

0 comments on commit d0c4eb2

Please sign in to comment.