docs: Convert code examples to JS
This commit is contained in:
@@ -68,7 +68,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Image ID',
|
||||
key: 'imageId',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The ID of the cat image you want to mark as favorite.',
|
||||
variables: true,
|
||||
@@ -104,7 +104,7 @@ export default defineAction({
|
||||
const imageId = $.step.parameters.imageId;
|
||||
|
||||
const headers = {
|
||||
'x-api-key': $.auth.data.apiKey as string,
|
||||
'x-api-key': $.auth.data.apiKey,
|
||||
};
|
||||
|
||||
const response = await $.http.post(
|
||||
|
@@ -60,7 +60,7 @@ export default {
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -72,7 +72,7 @@ export default {
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -118,7 +118,7 @@ export default {
|
||||
Let's create the `verify-credentials.js` file inside the `auth` folder.
|
||||
|
||||
```javascript
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
// 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.
|
||||
|
||||
```javascript
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.get('/v1/images/search');
|
||||
|
||||
await $.auth.set({
|
||||
@@ -172,7 +172,7 @@ Let's create the `is-still-verified.js` file inside the `auth` folder.
|
||||
```javascript
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
@@ -103,18 +103,18 @@ export default defineTrigger({
|
||||
let response;
|
||||
|
||||
const headers = {
|
||||
'x-api-key': $.auth.data.apiKey as string,
|
||||
'x-api-key': $.auth.data.apiKey,
|
||||
};
|
||||
|
||||
do {
|
||||
let requestPath = `/v1/images/search?page=${page}&limit=10&order=DESC`;
|
||||
response = await $.http.get(requestPath, { headers });
|
||||
|
||||
response.data.forEach((image: IJSONObject) => {
|
||||
response.data.forEach((image) => {
|
||||
const dataItem = {
|
||||
raw: image,
|
||||
meta: {
|
||||
internalId: image.id as string
|
||||
internalId: image.id
|
||||
},
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user