Skip to content

Commit

Permalink
fix: correct read changes curl snippet (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriantam authored Nov 28, 2024
1 parent c1e1cd3 commit 790b6e8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/Docs/SnippetViewer/ReadChangesRequestViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ function readChangesRequestViewer(lang: SupportedLanguage, opts: ReadChangesRequ
}`;
}
case SupportedLanguage.CURL: {
const typeString = `${opts.type ? '"type": ' + opts.type + '", ' : ''}`;
// eslint-disable-next-line max-len
const tokenString = `${opts.continuationToken ? '"continuation_token": "' + opts.continuationToken + '", ' : ''}`;
// eslint-disable-next-line max-len
const pageSizeString = `${opts.pageSize ? '"page_size": ' + opts.pageSize : ''}`;
return `curl -X POST $FGA_API_URL/stores/$FGA_STORE_ID/changes \\
let params = '';
if (opts.type) {
params = `?type=${opts.type}`;
}
if (opts.pageSize) {
params = `${params === '' ? '?' : params + '&'}` + `page_size=${opts.pageSize}`;
}
if (opts.continuationToken) {
params = `${params === '' ? '?' : params + '&'}` + `continuation_token=${opts.continuationToken}`;
}
return `curl -X GET $FGA_API_URL/stores/$FGA_STORE_ID/changes${params} \\
-H "Authorization: Bearer $FGA_API_TOKEN" \\ # Not needed if service does not require authorization
-H "content-type: application/json" \\
-d '{${typeString}${tokenString}${pageSizeString}}'`;
-H "content-type: application/json"`;
}

case SupportedLanguage.JS_SDK: {
Expand Down

0 comments on commit 790b6e8

Please sign in to comment.