( url: string, fields: Record<string, string | undefined>, format: "form" | "json", )
| 127 | >; |
| 128 | |
| 129 | const post = async ( |
| 130 | url: string, |
| 131 | fields: Record<string, string | undefined>, |
| 132 | format: "form" | "json", |
| 133 | ) => |
| 134 | fetch(url, { |
| 135 | method: "POST", |
| 136 | headers: { |
| 137 | "content-type": format === "json" ? "application/json" : "application/x-www-form-urlencoded", |
| 138 | accept: "application/json", |
| 139 | }, |
| 140 | body: format === "json" ? JSON.stringify(definedFields(fields)) : formBody(fields), |
| 141 | }); |
| 142 | |
| 143 | const readJson = async (response: Response): Promise<Record<string, unknown>> => { |
| 144 | const text = await response.text(); |
no test coverage detected