mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
feat: fetch effect (#1605)
* feat: fetch effect * fix: Make not available in sandbox * chore: Update to use text(), and to use headers * chore: use the postman echo for testing * chore: add json * chore: Testing the json * chore: Make the json lazy
This commit is contained in:
@@ -51,6 +51,20 @@ const warn = (x) => Deno.core.opSync("log_warn", x);
|
||||
const error = (x) => Deno.core.opSync("log_error", x);
|
||||
const debug = (x) => Deno.core.opSync("log_debug", x);
|
||||
const info = (x) => Deno.core.opSync("log_info", x);
|
||||
const fetch = async (url, options = null) => {
|
||||
const {body, ...response} = await Deno.core.opAsync("fetch", url, options);
|
||||
const textValue = Promise.resolve(body)
|
||||
return {
|
||||
...response,
|
||||
text() {
|
||||
return textValue
|
||||
},
|
||||
json() {
|
||||
return textValue.then(x => JSON.parse(x))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const currentFunction = Deno.core.opSync("current_function");
|
||||
const input = Deno.core.opSync("get_input");
|
||||
@@ -66,6 +80,7 @@ const effects = {
|
||||
trace,
|
||||
info,
|
||||
isSandboxed,
|
||||
fetch,
|
||||
removeFile,
|
||||
createDir,
|
||||
removeDir,
|
||||
|
||||
Reference in New Issue
Block a user