1
0
silverbullet/plugbox/syscall/fetch.node.ts

16 lines
451 B
TypeScript
Raw Normal View History

2022-03-25 11:03:06 +00:00
import fetch, { RequestInfo, RequestInit } from "node-fetch";
import { SysCallMapping } from "../system";
export function fetchSyscalls(): SysCallMapping {
return {
async fetchJson(ctx, url: RequestInfo, init: RequestInit) {
let resp = await fetch(url, init);
return resp.json();
},
async fetchText(ctx, url: RequestInfo, init: RequestInit) {
let resp = await fetch(url, init);
return resp.text();
},
};
}