docs: Convert code examples to JS

This commit is contained in:
Faruk AYDIN
2024-01-15 13:13:48 +01:00
parent 9ece9461dc
commit 8fcb7840de
3 changed files with 10 additions and 10 deletions

View File

@@ -68,7 +68,7 @@ export default defineAction({
{ {
label: 'Image ID', label: 'Image ID',
key: 'imageId', key: 'imageId',
type: 'string' as const, type: 'string',
required: true, required: true,
description: 'The ID of the cat image you want to mark as favorite.', description: 'The ID of the cat image you want to mark as favorite.',
variables: true, variables: true,
@@ -104,7 +104,7 @@ export default defineAction({
const imageId = $.step.parameters.imageId; const imageId = $.step.parameters.imageId;
const headers = { const headers = {
'x-api-key': $.auth.data.apiKey as string, 'x-api-key': $.auth.data.apiKey,
}; };
const response = await $.http.post( const response = await $.http.post(

View File

@@ -60,7 +60,7 @@ export default {
{ {
key: 'screenName', key: 'screenName',
label: 'Screen Name', label: 'Screen Name',
type: 'string' as const, type: 'string',
required: true, required: true,
readOnly: false, readOnly: false,
value: null, value: null,
@@ -72,7 +72,7 @@ export default {
{ {
key: 'apiKey', key: 'apiKey',
label: 'API Key', label: 'API Key',
type: 'string' as const, type: 'string',
required: true, required: true,
readOnly: false, readOnly: false,
value: null, value: null,
@@ -118,7 +118,7 @@ export default {
Let's create the `verify-credentials.js` file inside the `auth` folder. Let's create the `verify-credentials.js` file inside the `auth` folder.
```javascript ```javascript
const verifyCredentials = async ($: IGlobalVariable) => { const verifyCredentials = async ($) => {
// TODO: Implement verification of the credentials // TODO: Implement verification of the credentials
}; };
@@ -130,7 +130,7 @@ We generally use the `users/me` endpoint or any other endpoint that we can valid
Let's implement the authentication logic that we mentioned above in the `verify-credentials.js` file. Let's implement the authentication logic that we mentioned above in the `verify-credentials.js` file.
```javascript ```javascript
const verifyCredentials = async ($: IGlobalVariable) => { const verifyCredentials = async ($) => {
await $.http.get('/v1/images/search'); await $.http.get('/v1/images/search');
await $.auth.set({ await $.auth.set({
@@ -172,7 +172,7 @@ Let's create the `is-still-verified.js` file inside the `auth` folder.
```javascript ```javascript
import verifyCredentials from './verify-credentials.js'; import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($: IGlobalVariable) => { const isStillVerified = async ($) => {
await verifyCredentials($); await verifyCredentials($);
return true; return true;
}; };

View File

@@ -103,18 +103,18 @@ export default defineTrigger({
let response; let response;
const headers = { const headers = {
'x-api-key': $.auth.data.apiKey as string, 'x-api-key': $.auth.data.apiKey,
}; };
do { do {
let requestPath = `/v1/images/search?page=${page}&limit=10&order=DESC`; let requestPath = `/v1/images/search?page=${page}&limit=10&order=DESC`;
response = await $.http.get(requestPath, { headers }); response = await $.http.get(requestPath, { headers });
response.data.forEach((image: IJSONObject) => { response.data.forEach((image) => {
const dataItem = { const dataItem = {
raw: image, raw: image,
meta: { meta: {
internalId: image.id as string internalId: image.id
}, },
}; };