Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var axios = require('axios');
- var FormData = require('form-data');
- var fs = require('fs');
- var data = new FormData();
- data.append('avatar', fs.createReadStream('/path/to/file'));
- data.append('height', '180');
- data.append('skin', '1');
- data.append('userId', 'f1cddced-8cc5-4086-a6af-0af9d6be0ae5');
- var config = {
- method: 'post',
- url: 'http://localhost:3000/test',
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/json',
- ...data.getHeaders()
- },
- data : data
- };
- axios(config)
- .then(function (response) {
- console.log(JSON.stringify(response.data));
- })
- .catch(function (error) {
- console.log(error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement