Skip to content

Commit

Permalink
- Fixed: Typos
Browse files Browse the repository at this point in the history
- Added: Links to the methods
  • Loading branch information
JBtje committed Jun 30, 2019
1 parent e93ed8d commit 37350fa
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Readme.md
Expand Up @@ -186,7 +186,17 @@ form.submit({

### Methods

##### _void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
- [_Array_ getHeaders( [**Array** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)

#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
```javascript
var form = new FormData();
Expand All @@ -206,18 +216,18 @@ form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', filesize: 1045} );
```

##### _Array_ getHeaders( [**Array** _userHeaders_] )
#### _Array_ getHeaders( [**Array** _userHeaders_] )
This method ads the correct `content-type` header to the provided array of `userHeaders`.

##### _String_ getBoundary()
Return the boundary of the formData. A boundary consists of 26x `-` followed by 24 numbers
#### _String_ getBoundary()
Return the boundary of the formData. A boundary consists of 26 `-` followed by 24 numbers
for example:
```javascript
--------------------------515890814546601021194782
```
_Note: The boundary must be unique and may not appear in the data._

##### _Buffer_ getBuffer()
#### _Buffer_ getBuffer()
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.

```javascript
Expand All @@ -231,12 +241,12 @@ axios.post( 'https://example.com/path/to/api',
)
```

##### _Integer_ getLengthSync()
#### _Integer_ getLengthSync()
Same as `getLength` but synchronous.

_Note: getLengthSync __doesn't__ calculate streams length._

##### _Integer_ getLength( function _callback_ )
#### _Integer_ getLength( **function** _callback_ )
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
```javascript
this.getLength(function(err, length) {
Expand All @@ -252,10 +262,10 @@ this.getLength(function(err, length) {
}.bind(this));
```

##### _boolean_ hasKnownLength()
#### _Boolean_ hasKnownLength()
Checks if the length of added values is known.

##### _request_ submit( _params_, function _callback_ )
#### _Request_ submit( _params_, **function** _callback_ )
Submit the form to a web application.
```javascript
var form = new FormData();
Expand All @@ -267,7 +277,7 @@ form.submit( 'http://example.com/', function(err, res) {
} );
```

##### _String_ toString()
#### _String_ toString()
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.

### Integration with other libraries
Expand Down

0 comments on commit 37350fa

Please sign in to comment.