Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
531 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var needle = require('./../');
|
---|
| 2 |
|
---|
| 3 | var url = 'http://posttestserver.com/post.php?dir=needle';
|
---|
| 4 |
|
---|
| 5 | var black_pixel = Buffer.from("R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", 'base64');
|
---|
| 6 |
|
---|
| 7 | var data = {
|
---|
| 8 | foo: 'bar',
|
---|
| 9 | nested: {
|
---|
| 10 | test: 123
|
---|
| 11 | },
|
---|
| 12 | image: { buffer: black_pixel, content_type: 'image/gif' }
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | var resp = needle.post(url, data, { multipart: true });
|
---|
| 16 |
|
---|
| 17 | resp.on('readable', function() {
|
---|
| 18 | while (data = this.read()) {
|
---|
| 19 | console.log(data.toString());
|
---|
| 20 | }
|
---|
| 21 | })
|
---|
| 22 |
|
---|
| 23 | resp.on('done', function(data) {
|
---|
| 24 | console.log('Done.');
|
---|
| 25 | })
|
---|
Note:
See
TracBrowser
for help on using the repository browser.