Edits history of script submission #11456 for ' Send POST Request (http)'

  • bun
    export async function main(url: string, body: object = {}, headers: Record<string, string> = {}) {
      const resp = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          ...headers, 
        },
        body: JSON.stringify(body),
      });
    
      return {
        ok: resp.ok,
        status: resp.status,
        text: await resp.text(),
      };
    }
    

    Submitted by alif ramdani585 455 days ago