MCPcopy Create free account
hub / github.com/ShaanCoding/makeread.me / getFormData

Function getFormData

frontend/openAPI/generated/core/request.ts:103–128  ·  view source on GitHub ↗
(options: ApiRequestOptions)

Source from the content-addressed store, hash-verified

101};
102
103export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
104 if (options.formData) {
105 const formData = new FormData();
106
107 const process = (key: string, value: any) => {
108 if (isString(value) || isBlob(value)) {
109 formData.append(key, value);
110 } else {
111 formData.append(key, JSON.stringify(value));
112 }
113 };
114
115 Object.entries(options.formData)
116 .filter(([_, value]) => isDefined(value))
117 .forEach(([key, value]) => {
118 if (Array.isArray(value)) {
119 value.forEach(v => process(key, v));
120 } else {
121 process(key, value);
122 }
123 });
124
125 return formData;
126 }
127 return undefined;
128};
129
130type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
131

Callers 1

requestFunction · 0.85

Calls 2

isDefinedFunction · 0.85
processFunction · 0.85

Tested by

no test coverage detected