From ba1cc9105e4401a219133e45a4ffbce4401fbffc Mon Sep 17 00:00:00 2001 From: Henri Courdent <122811744+hcourdent@users.noreply.github.com> Date: Mon, 21 Aug 2023 12:55:57 +0200 Subject: [PATCH] Updated default Rest and clear_rest (#2140) --- frontend/src/lib/script_helpers.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts index 9b81c83bd3..5b4847b3d8 100644 --- a/frontend/src/lib/script_helpers.ts +++ b/frontend/src/lib/script_helpers.ts @@ -15,6 +15,17 @@ export { export const NATIVETS_INIT_CODE = `// Fetch-only script, no imports allowed but benefits from a dedicated highly efficient runtime +export async function main(example_input: number = 3) { + // "3" is the default value of example_input, it can be overriden with code or using the UI + const res = await fetch(\`https://jsonplaceholder.typicode.com/todos/\${example_input}\`, { + headers: { "Content-Type": "application/json" }, + }); + return res.json(); +} +` + +export const NATIVETS_INIT_CODE_CLEAR = `// Fetch-only script, no imports allowed but benefits from a dedicated highly efficient runtime + export async function main() { const res = await fetch("https://jsonplaceholder.typicode.com/todos/1", { headers: { "Content-Type": "application/json" }, @@ -376,6 +387,8 @@ export function getResetCode( return DENO_INIT_CODE_CLEAR } else if (language === 'python3') { return PYTHON_INIT_CODE_CLEAR + } else if (language === 'nativets') { + return NATIVETS_INIT_CODE_CLEAR } else if (language === 'bun') { return BUN_INIT_CODE_CLEAR } else {