Skip to content

Commit

Permalink
Updating JS/TS docs to make it clear where async promises are being r…
Browse files Browse the repository at this point in the history
…eturned

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
  • Loading branch information
ShivanshVij committed Mar 20, 2023
1 parent 55f9c55 commit 38a8dae
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions docs/languages/javascript-typescript/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,16 @@ it.
<Tab title="Embedding the Function With Webpack">
```javascript
import { New } from "@loopholelabs/scale";
// @ts-ignore
import sf from "./hello-world.scale";

const r = New([sf]);

const i = r.Instance(null);
i.Context().Request.Body = "Hello, World!";

i.Run()
console.log(i.Context().Response.Body);
(async () => {
const r = await New([sf]);
const i = await r.Instance(null);
i.Context().Request.Body = "Hello, World!";
i.Run()
console.log(i.Context().Response.Body);
})();
```
</Tab>
<Tab title="Embedding the Function Without Webpack">
Expand All @@ -176,13 +177,14 @@ it.
import { Read } from "@loopholelabs/scalefile/scalefunc/helpers";

const sf = Read("./hello-world.scale");
const r = New([sf]);

const i = r.Instance(null);
i.Context().Request.Body = "Hello, World!";

i.Run()
console.log(i.Context().Response.Body);
(async () => {
const r = await New([sf]);
const i = await r.Instance(null);
i.Context().Request.Body = "Hello, World!";
i.Run()
console.log(i.Context().Response.Body);
})();
```
</Tab>
<Tab title="Using the Scale Registry">
Expand All @@ -191,13 +193,13 @@ it.
import { New } from "@loopholelabs/scale";

const sf = Download("hello-world", "latest");
const r = New([sf]);

const i = r.Instance(null);
i.Context().Request.Body = "Hello, World!";

i.Run()
console.log(i.Context().Response.Body);
(async () => {
const r = await New([sf]);
const i = await r.Instance(null);
i.Context().Request.Body = "Hello, World!";
i.Run()
console.log(i.Context().Response.Body);
})();
```
</Tab>
</Tabs>
Expand Down

0 comments on commit 38a8dae

Please sign in to comment.