Advertisement
simonedare_

Uploading Avatar 3D

Feb 2nd, 2024 (edited)
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var axios = require('axios');
  2. var FormData = require('form-data');
  3. var fs = require('fs');
  4. var data = new FormData();
  5. data.append('avatar', fs.createReadStream('/path/to/file'));
  6. data.append('height', '180');
  7. data.append('skin', '1');
  8. data.append('userId', 'f1cddced-8cc5-4086-a6af-0af9d6be0ae5');
  9.  
  10. var config = {
  11.   method: 'post',
  12.   url: 'http://localhost:3000/test',
  13.   headers: {
  14.     'Content-Type': 'application/json',
  15.     'Accept': 'application/json',
  16.     ...data.getHeaders()
  17.   },
  18.   data : data
  19. };
  20.  
  21. axios(config)
  22. .then(function (response) {
  23.   console.log(JSON.stringify(response.data));
  24. })
  25. .catch(function (error) {
  26.   console.log(error);
  27. });
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement