MCPcopy Create free account
hub / github.com/nodejs/node / formData

Function formData

deps/undici/undici.js:6873–6898  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6871 return consumeBody(this, parseJSONFromBytes, instance, getInternalState);
6872 },
6873 formData() {
6874 return consumeBody(this, (value) => {
6875 const mimeType = bodyMimeType(getInternalState(this));
6876 if (mimeType !== null) {
6877 switch (mimeType.essence) {
6878 case "multipart/form-data": {
6879 const parsed = multipartFormDataParser(value, mimeType);
6880 const fd = new FormData();
6881 setFormDataState(fd, parsed);
6882 return fd;
6883 }
6884 case "application/x-www-form-urlencoded": {
6885 const entries = new URLSearchParams(value.toString());
6886 const fd = new FormData();
6887 for (const [name, value2] of entries) {
6888 fd.append(name, value2);
6889 }
6890 return fd;
6891 }
6892 }
6893 }
6894 throw new TypeError(
6895 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
6896 );
6897 }, instance, getInternalState);
6898 },
6899 bytes() {
6900 return consumeBody(this, (bytes) => {
6901 return new Uint8Array(bytes);

Callers

nothing calls this directly

Calls 5

appendMethod · 0.95
consumeBodyFunction · 0.70
bodyMimeTypeFunction · 0.70
multipartFormDataParserFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected