Skip to content

Commit 265b712

Browse files
authored
docs: fix deprecated Buffer constructor and formatting issues in README (#7371)
1 parent 475e75a commit 265b712

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ cancel();
10681068
10691069
### URLSearchParams
10701070
1071-
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018).
1071+
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) format instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers, and [Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018).
10721072
10731073
```js
10741074
const params = new URLSearchParams({ foo: "bar" });
@@ -1187,7 +1187,7 @@ const FormData = require("form-data");
11871187

11881188
const form = new FormData();
11891189
form.append("my_field", "my value");
1190-
form.append("my_buffer", new Buffer(10));
1190+
form.append("my_buffer", Buffer.alloc(10));
11911191
form.append("my_file", fs.createReadStream("/foo/bar.jpg"));
11921192

11931193
axios.post("https://example.com", form);
@@ -1228,7 +1228,7 @@ var FormData = require("form-data");
12281228
axios
12291229
.post(
12301230
"https://httpbin.org/post",
1231-
{ x: 1, buf: new Buffer(10) },
1231+
{ x: 1, buf: Buffer.alloc(10) },
12321232
{
12331233
headers: {
12341234
"Content-Type": "multipart/form-data",

0 commit comments

Comments
 (0)