Axios de CreaterAreadstream
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 ...',
},
});
Concerned Chicken