Skip to content

Commit

Permalink
docs: use provided function and client values for datastore calls (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeg authored Jul 29, 2024
1 parent 7589d49 commit 57d62e5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docs/datastores.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ Now that you have a Datastore all set up, you can use it in your
instantiate your client, and make an API call to one of the Datastore endpoints!

```ts
import { SlackAPI } from "deno_slack_api/mod.ts";
import { SlackFunction } from "deno_slack_api/mod.ts";

const reverse = async ({ inputs, env, token }: any) => {
export default SlackFunction(ReverseFunction, async ({ client, inputs }) => {
const original = inputs.stringToReverse;
const recordId = crypto.randomUUID();
const reversed = inputs.stringToReverse.split("").reverse().join("");

const client = SlackAPI(token, {});
const putResp = await client.apiCall("apps.datastore.put", {
const putResp = await client.apps.datastore.put({
datastore: "reversals",
item: {
id: recordId,
Expand All @@ -76,12 +75,12 @@ const reverse = async ({ inputs, env, token }: any) => {
},
});
if (!putResp.ok) {
return await {
completed: false,
return {
error: putResp.error,
};
}
...
// ...
});
```

[functions]: ./functions.md
Expand Down

0 comments on commit 57d62e5

Please sign in to comment.