Send POST Request
Send an HTTP POST request with a JSON body and optional headers.
| 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 |