“NodeJs Modul Minta” Kode Jawaban

node js memang meminta

let request = require('request')

const formData = {
  // Pass a simple key-value pair
  my_field: 'my_value',
  // Pass data via Buffers
  my_buffer: Buffer.from([1, 2, 3]),
  // Pass data via Streams
  my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
  // Pass multiple values /w an Array
  attachments: [
    fs.createReadStream(__dirname + '/attachment1.jpg'),
    fs.createReadStream(__dirname + '/attachment2.jpg')
  ],
  // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
  // Use case: for some types of streams, you'll need to provide "file"-related information manually.
  // See the `form-data` README for more information about options: https://github.com/form-data/form-data
  custom_file: {
    value:  fs.createReadStream('/dev/urandom'),
    options: {
      filename: 'topsecret.jpg',
      contentType: 'image/jpeg'
    }
  }
};
request.post({url:'http://service.com/upload', formData: formData}, function optionalCallback(err, httpResponse, body) {
  if (err) {
    return console.error('upload failed:', err);
  }
  console.log('Upload successful!  Server responded with:', body);
});
Jules

NodeJs Modul Minta

request  .get('http://google.com/img.png')
  .on('response', function(response) {
  console.log(response.statusCode) // 200
  console.log(response.headers['content-type']) // 'image/png'  }) 
    .pipe(request.put('http://mysite.com/img.png'))
Jinal_Patel

Jawaban yang mirip dengan “NodeJs Modul Minta”

Pertanyaan yang mirip dengan “NodeJs Modul Minta”

Lebih banyak jawaban terkait untuk “NodeJs Modul Minta” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya