aboutsummaryrefslogtreecommitdiff
path: root/demo/src/compile.ts
blob: 7ca7a7211c86139ef72bcf9e778a2117f72878e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const url = 'https://hexi.wokwi.com';

export interface HexiResult {
  stdout: string;
  stderr: string;
  hex: string;
}

export async function buildHex(source: string) {
  const resp = await fetch(url + '/build', {
    method: 'POST',
    mode: 'cors',
    cache: 'no-cache',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ sketch: source })
  });
  return (await resp.json()) as HexiResult;
}