source: trip-planner-front/node_modules/needle/examples/multipart-stream.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 531 bytes
RevLine 
[6a3a178]1var needle = require('./../');
2
3var url = 'http://posttestserver.com/post.php?dir=needle';
4
5var black_pixel = Buffer.from("R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", 'base64');
6
7var data = {
8 foo: 'bar',
9 nested: {
10 test: 123
11 },
12 image: { buffer: black_pixel, content_type: 'image/gif' }
13}
14
15var resp = needle.post(url, data, { multipart: true });
16
17resp.on('readable', function() {
18 while (data = this.read()) {
19 console.log(data.toString());
20 }
21})
22
23resp.on('done', function(data) {
24 console.log('Done.');
25})
Note: See TracBrowser for help on using the repository browser.