1
0
silverbullet/plugos/syscalls/fetch.node.ts
2022-04-04 11:51:41 +02:00

16 lines
463 B
TypeScript

import fetch, {RequestInfo, RequestInit} from "node-fetch";
import {SysCallMapping} from "../system";
export function fetchSyscalls(): SysCallMapping {
return {
"fetch.json": async (ctx, url: RequestInfo, init: RequestInit) => {
let resp = await fetch(url, init);
return resp.json();
},
"fetch.text": async (ctx, url: RequestInfo, init: RequestInit) => {
let resp = await fetch(url, init);
return resp.text();
},
};
}