MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / post

Function post

apps/cli/src/device-login.ts:158–176  ·  view source on GitHub ↗
(
  url: string,
  fields: Record<string, string | undefined>,
  format: "form" | "json",
  options: DeviceLoginHttpOptions = {},
)

Source from the content-addressed store, hash-verified

156};
157
158const 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
178const readJson = async (response: Response): Promise<Record<string, unknown>> => {
179 const text = await response.text();

Callers 3

requestDeviceCodeFunction · 0.70
pollForDeviceTokensFunction · 0.70
refreshDeviceTokensFunction · 0.70

Calls 4

headersForUrlFunction · 0.85
definedFieldsFunction · 0.85
formBodyFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected