Send POST Request

Send an HTTP POST request with a JSON body and optional headers.

typescript · 13 lines
1
export async function main(
2
  url: string,
3
  body: object = {},
4
  headers: Record<string, string> = {}
5
) {
6
  const response = await fetch(url, {
7
    method: 'POST',
8
    headers: { 'Content-Type': 'application/json', ...headers },
9
    body: JSON.stringify(body)
10
  })
11
  return await response.json()
12
}
13
 
Orvanta Hub — community scripts, flows, apps & resource types.