Skip to content

Commit

Permalink
feat: update ApiRequest to accept POST w/o payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Apr 27, 2022
1 parent 9a0226d commit 65da8a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions website/src/components/ApiRequest/ApiRequest.stories.jsx
Expand Up @@ -31,6 +31,13 @@ POST.args = {
title: 'Create a feature toggle with impression data enabled. (example)',
};

export const POSTWithoutPayload = Template.bind({});
POSTWithoutPayload.args = {
verb: 'post',
url: 'api/admin/projects/<projectId>/features/<featureName>/environments/<environment>/on',
title: 'Disable a toggle in an env.',
};

export const PUT = Template.bind({});
PUT.args = {
verb: 'put',
Expand Down
6 changes: 5 additions & 1 deletion website/src/components/ApiRequest/index.tsx
Expand Up @@ -68,6 +68,9 @@ curl -H "Content-Type: application/json" \\
<${baseUrl}>/${url}`
).trim();

const httpieBlockFormatSpecifier =
verbUpper === 'POST' && !prettyPayload ? '--json' : '';

const httpieBlock = (
payload
? `echo '${prettyPayload}' \\
Expand All @@ -77,7 +80,8 @@ curl -H "Content-Type: application/json" \\
: `
http ${verbUpper} \\
<${baseUrl}>/${url} \\
Authorization:<${authToken}>`.trim()
Authorization:<${authToken}> \\
${httpieBlockFormatSpecifier}`.trim()
).trim();

return (
Expand Down

0 comments on commit 65da8a8

Please sign in to comment.