1
0
silverbullet/plugos/syscall/fetch.node.ts
2022-03-27 11:31:12 +02:00

16 lines
441 B
TypeScript

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