Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

createReadStream axios

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs/promises');

// Read image from disk as a Buffer
const image = await fs.readFile('./stickers.jpg');

// Create a form and append image with additional fields
const form = new FormData();
form.append('productName', 'Node.js Stickers');
form.append('productDescription', 'Cool collection of Node.js stickers for your laptop.');
form.append('productImage', image, 'stickers.jpg');

// Send form data with axios
const response = await axios.post('https://example.com', form, {
  headers: {
    ...form.getHeaders(),
    Authentication: 'Bearer ...',
  },
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: js pick last element of array 
Javascript :: react native file pdf to base64 
Javascript :: insertmany 
Javascript :: javascript neue zeilekill 
Javascript :: javascript if object element exists 
Javascript :: how to run react app on apache server 
Javascript :: p cannot appear as a descendant of p react 
Javascript :: javascript Non-numeric String Results to NaN 
Javascript :: truthy or falsy 
Javascript :: JavaScript, numbers are primitive data types 
Javascript :: javascript Passing Parameter as Default Values 
Javascript :: javascript for...of with Sets 
Javascript :: javascript variable name arguments and eval are not allowed 
Javascript :: JavaScript HTML DOM Node Lists 
Javascript :: disable SerializableStateInvariantMiddleware and ImmutableStateInvariantMiddleware middlewares for large redux stores 
Javascript :: ex: javascript Executor 
Javascript :: OpenTok Create Session 
Javascript :: javascript equality operator 
Javascript :: phaser grid align 
Javascript :: phaser animation from json 
Javascript :: Horizontal scroll to anchor 
Javascript :: nodejs where multiple condition findAll 
Javascript :: javascript search an array of json for matching attribute 
Javascript :: mongo db backup node js daily 
Javascript :: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 
Javascript :: add line break in innerhtml 
Javascript :: how to add google map in react js 
Javascript :: javascript no decimal places 
Javascript :: ternary operator in javascript 
Javascript :: get array from string javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =