(
url: string,
fields: Record<string, string | undefined>,
format: "form" | "json",
options: DeviceLoginHttpOptions = {},
)
| 156 | }; |
| 157 | |
| 158 | const post = async ( |
| 159 | url: string, |
| 160 | fields: Record<string, string | undefined>, |
| 161 | format: "form" | "json", |
| 162 | options: DeviceLoginHttpOptions = {}, |
| 163 | ) => |
| 164 | fetch(url, { |
| 165 | method: "POST", |
| 166 | headers: headersForUrl( |
| 167 | url, |
| 168 | { |
| 169 | "content-type": |
| 170 | format === "json" ? "application/json" : "application/x-www-form-urlencoded", |
| 171 | accept: "application/json", |
| 172 | }, |
| 173 | options, |
| 174 | ), |
| 175 | body: format === "json" ? JSON.stringify(definedFields(fields)) : formBody(fields), |
| 176 | }); |
| 177 | |
| 178 | const readJson = async (response: Response): Promise<Record<string, unknown>> => { |
| 179 | const text = await response.text(); |
no test coverage detected