Merge branch 'Thinatic/feature-aiscript-restapi' into honi-dev
This commit is contained in:
commit
3b49cb4e27
@ -39,5 +39,18 @@ export function createAiScriptEnv(opts) {
|
||||
utils.assertString(key);
|
||||
return utils.jsToVal(JSON.parse(localStorage.getItem('aiscript:' + opts.storageKey + ':' + key.value)));
|
||||
}),
|
||||
'Mk:fetch': values.FN_NATIVE(async ([resource, init]) => {
|
||||
utils.assertString(resource);
|
||||
const response = init ? await fetch(resource.value, utils.valToJs(init)) : await fetch(resource.value);
|
||||
const returnObject = {
|
||||
status: response.status,
|
||||
headers: new Object(),
|
||||
body: await response.text(),
|
||||
};
|
||||
response.headers.forEach((value, key) => {
|
||||
returnObject.headers[key] = value;
|
||||
});
|
||||
return utils.jsToVal(returnObject);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user