Send POST Request

Script http Verified

by danielmurvi ยท 6/6/2022

The script

Submitted by rubenfiszel Typescript (fetch-only)
Verified 442 days ago
1
export async function main(url: string, body: object = {}, headers: Record<string, string> = {}) {
2
  const resp = await fetch(url, {
3
    method: "POST",
4
    headers: {
5
      "Content-Type": "application/json",
6
      ...headers, 
7
    },
8
    body: JSON.stringify(body),
9
  });
10

11
  return {
12
    ok: resp.ok,
13
    status: resp.status,
14
    text: await resp.text(),
15
  };
16
}
17

Other submissions
  • Submitted by jaller94 Deno
    Created 1387 days ago
    1
    export async function main(url: string, body: object = {}) {
    2
        const resp = await fetch(url, {
    3
            method: "POST",
    4
            headers: {
    5
                "Content-Type": "application/json",
    6
            },
    7
            body: JSON.stringify(body),
    8
        });
    9
    
    
    10
        return {
    11
            ok: resp.ok,
    12
            status: resp.status,
    13
            text: await resp.text(),
    14
        };
    15
    }
  • Submitted by alif ramdani585 Bun
    Created 455 days ago
    1
    export async function main(url: string, body: object = {}, headers: Record<string, string> = {}) {
    2
      const resp = await fetch(url, {
    3
        method: "POST",
    4
        headers: {
    5
          "Content-Type": "application/json",
    6
          ...headers, 
    7
        },
    8
        body: JSON.stringify(body),
    9
      });
    10
    
    
    11
      return {
    12
        ok: resp.ok,
    13
        status: resp.status,
    14
        text: await resp.text(),
    15
      };
    16
    }
    17
    
    
  • Submitted by chivauva1435 Bun
    Created 190 days ago
    1
    // import * as wmill from 'windmill-client'
    2
    
    
    3
    export async function main(x: string) {
    4
      return x
    5
    }
  • Submitted by rossmccrann Deno
    Created 1421 days ago
    1
    export async function main(url: string, body: object) {
    2
    
    
    3
        let resp = await fetch(url, {
    4
            method: "POST",
    5
            headers: {
    6
                "Content-Type": "application/json",
    7
                "X-API-Key": "foobar",
    8
            },
    9
            body,
    10
            });
    11
    
    
    12
    	return { "response": await resp.text() }
    13
    }