Send PUT Request

Script http Verified

by maximelambercier ยท 6/6/2022

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 days ago
1
//native
2

3
export async function main(url: string, body: object = {}) {
4
  const resp = await fetch(url, {
5
    method: "PUT",
6
    headers: {
7
      "Content-Type": "application/json",
8
    },
9
    body: JSON.stringify(body),
10
  });
11

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

Other submissions
  • Submitted by jaller94 Deno
    Created 397 days ago
    1
    export async function main(url: string, body: object = {}) {
    2
      const resp = await fetch(url, {
    3
        method: "PUT",
    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
    }
    16
    
    
  • Submitted by rossmccrann Deno
    Created 1432 days ago
    1
    export async function main(url: string, body: object) {
    2
    
    
    3
        let resp = await fetch(url, {
    4
            method: "PUT",
    5
            headers: {
    6
                "Content-Type": "application/json",
    7
            },
    8
            body,
    9
            });
    10
    
    
    11
    	return { "response": await resp.text() }
    12
    }