@@ -14,7 +14,7 @@ Encode `FormData` content into the `multipart/form-data` format
1414import {Readable } from " stream"
1515
1616import {FormData , File } from " formdata-node"
17- import {Encoder } from " form-data-encoder"
17+ import {FormDataEncoder } from " form-data-encoder"
1818
1919import fetch from " node-fetch"
2020
@@ -23,7 +23,7 @@ const fd = new FormData()
2323fd .set (" greeting" , " Hello, World!" )
2424fd .set (" file" , new File ([" On Soviet Moon landscape see binoculars through YOU" ], " file.txt" ))
2525
26- const encoder = new Encoder (fd)
26+ const encoder = new FormDataEncoder (fd)
2727
2828const options = {
2929 method: " post" ,
@@ -48,15 +48,15 @@ console.log(await response.json())
4848``` js
4949import {Readable } from " stream"
5050
51- import {Encoder } from " form-data-encoder"
51+ import {FormDataEncoder } from " form-data-encoder"
5252import {FormData , File } from " formdata-polyfill/esm-min.js"
5353
5454const fd = new FormData ()
5555
5656fd .set (" field" , " Some value" )
5757fd .set (" file" , new File ([" File content goes here" ], " file.txt" ))
5858
59- const encoder = new Encoder (fd)
59+ const encoder = new FormDataEncoder (fd)
6060
6161const options = {
6262 method: " post" ,
@@ -72,7 +72,7 @@ await fetch("https://httpbin.org/post", options)
7272``` js
7373import {Readable } from " stream"
7474
75- import {Encoder } from " form-data-encoder"
75+ import {FormDataEncoder } from " form-data-encoder"
7676
7777import {FormData , File , Blob , fileFromPath } from " formdata-node"
7878
@@ -84,7 +84,7 @@ fd.set("field", "Just a random string")
8484fd .set (" file" , new File ([" Using files is class amazing" ], " file.txt" ))
8585fd .set (" fileFromPath" , await fileFromPath (" path/to/a/file.txt" ))
8686
87- const encoder = new Encoder (fd)
87+ const encoder = new FormDataEncoder (fd)
8888
8989const options = {
9090 method: " post" ,
@@ -104,7 +104,7 @@ console.log(await response.json())
104104``` js
105105import {FormData } from " formdata-polyfill/esm-min.js"
106106import {blobFrom } from " fetch-blob/from.js"
107- import {Encoder } from " form-data-encoder"
107+ import {FormDataEncoder } from " form-data-encoder"
108108
109109import Blob from " fetch-blob"
110110import fetch from " node-fetch"
@@ -140,7 +140,7 @@ import {Readable} from "stream"
140140
141141import {FormData } from " formdata-polyfill/esm-min.js"
142142import {blobFrom } from " fetch-blob/from.js"
143- import {Encoder } from " form-data-encoder"
143+ import {FormDataEncoder } from " form-data-encoder"
144144
145145import Blob from " fetch-blob"
146146import fetch from " node-fetch"
@@ -174,7 +174,7 @@ const fd = new FormData()
174174fd .set (" name" , " John Doe" )
175175fd .set (" avatar" , await blobFrom (" path/to/an/avatar.png" ), " avatar.png" )
176176
177- const encoder = new Encoder (fd)
177+ const encoder = new FormDataEncoder (fd)
178178
179179// Note that node-fetch@2 performs more strictness tests for Blob objects, so you may need to do extra steps before you set up request body (like, maybe you'll need to instaniate a Blob with BlobDataItem as one of its blobPart)
180180const blob = new BlobDataItem (enocoder) // or new Blob([new BlobDataItem(enocoder)], {type: encoder.contentType})
@@ -193,7 +193,7 @@ await fetch("https://httpbin.org/post", options)
193193 // This module is only necessary when you targeting Node.js or need web streams that implement Symbol.asyncIterator
194194import {ReadableStream } from " web-streams-polyfill/ponyfill/es2018"
195195
196- import {Encoder } from " form-data-encoder"
196+ import {FormDataEncoder } from " form-data-encoder"
197197import {FormData } from " formdata-node"
198198
199199import fetch from " node-fetch"
@@ -214,7 +214,7 @@ const fd = new FormData()
214214
215215fd .set (" field" , " My hovercraft is full of eels" )
216216
217- const encoder = new Encoder (fd)
217+ const encoder = new FormDataEncoder (fd)
218218
219219const options = {
220220 method: " post" ,
@@ -229,7 +229,7 @@ await fetch("https://httpbin.org/post", options)
2292297 . Speaking of async iterables - if HTTP client supports them, you can use encoder like this:
230230
231231``` js
232- import {Encoder } from " form-data-encoder"
232+ import {FormDataEncoder } from " form-data-encoder"
233233import {FormData } from " formdata-node"
234234
235235import fetch from " node-fetch"
@@ -238,7 +238,7 @@ const fd = new FormData()
238238
239239fd .set (" field" , " My hovercraft is full of eels" )
240240
241- const encoder = new Encoder (fd)
241+ const encoder = new FormDataEncoder (fd)
242242
243243const options = {
244244 method: " post" ,
@@ -291,7 +291,7 @@ pnpm add form-data-encoder
291291
292292## API
293293
294- ### ` class Encoder `
294+ ### ` class FormDataEncoder `
295295
296296##### ` constructor(form[, boundary]) -> {Encoder} `
297297
0 commit comments